Skip to content

feat(ivy): add ability to inspect local refs through context discovery #26117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

pkozlowski-opensource
Copy link
Member

This is needed for the TestBed implementation since we can ask for a set of local refs on a given debug element.

@pkozlowski-opensource pkozlowski-opensource added action: review The PR is still awaiting reviews from at least one requested reviewer target: major This PR is targeted for the next major release comp: ivy labels Sep 26, 2018
@mary-poppins
Copy link

You can preview f797bd5 at https://pr26117-f797bd5.ngbuilds.io/.

selectors: [['comp']],
factory: () => new Comp(),
consts: 1,
vars: 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be 3 consts and 0 vars, no?

for (let i = 0; i < tNode.localNames.length; i += 2) {
const localRefName = tNode.localNames[i];
const directiveIndex = tNode.localNames[i + 1] as number;
result[localRefName] = directiveIndex === -1 ? lViewData[lNodeIndex].native :
Copy link
Contributor

@kara kara Sep 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to wrap lViewData[lNodeIndex] with readElementValue in case that element happens to have a styling context. You might want to use getLNode(), since it has that built in. (Maybe a test for this?)

const localRefName = tNode.localNames[i];
const directiveIndex = tNode.localNames[i + 1] as number;
result[localRefName] = directiveIndex === -1 ? lViewData[lNodeIndex].native :
lViewData[DIRECTIVES] ![directiveIndex];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about local refs on ng-template elements? Is that something we want to support?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I don't need it for TestBed but we should add it for completeness + a test. Thnx for catching this!

Copy link
Contributor

@kara kara Sep 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, if it's not necessary for TestBed, we could probably just make a JIRA ticket for later. Was just curious what your thoughts were on supporting it down the line.

Copy link
Contributor

@matsko matsko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an excellent feature.

Copy link
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please take care of the comments.

directives: Array<{}>|null|undefined;
directives: any[]|null|undefined;

/** The map of local references (local reference name => element or directive instance) that exist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: /** should not have text after it. (insert line break).

@mhevery mhevery added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 27, 2018
@pkozlowski-opensource pkozlowski-opensource force-pushed the discovery_util_local_refs branch 2 times, most recently from 43bd538 to 725b4a3 Compare September 27, 2018 14:05
@mary-poppins
Copy link

You can preview 43bd538 at https://pr26117-43bd538.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 725b4a3 at https://pr26117-725b4a3.ngbuilds.io/.

@pkozlowski-opensource pkozlowski-opensource removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Sep 27, 2018
@mary-poppins
Copy link

You can preview fa0ec85 at https://pr26117-fa0ec85.ngbuilds.io/.

@pkozlowski-opensource pkozlowski-opensource added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Sep 27, 2018
@pkozlowski-opensource
Copy link
Member Author

Marking as merge-assistance since:

@mary-poppins
Copy link

You can preview 8f522ba at https://pr26117-8f522ba.ngbuilds.io/.

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kara
Copy link
Contributor

kara commented Sep 27, 2018

presubmit

@kara kara added action: merge The PR is ready for merge by the caretaker and removed merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Sep 27, 2018
@alxhub alxhub closed this in 5f6900e Sep 27, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants