-
Notifications
You must be signed in to change notification settings - Fork 26.3k
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
feat(ivy): add ability to inspect local refs through context discovery #26117
Conversation
You can preview f797bd5 at https://pr26117-f797bd5.ngbuilds.io/. |
selectors: [['comp']], | ||
factory: () => new Comp(), | ||
consts: 1, | ||
vars: 1, |
There was a problem hiding this comment.
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 : |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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).
43bd538
to
725b4a3
Compare
You can preview 43bd538 at https://pr26117-43bd538.ngbuilds.io/. |
You can preview 725b4a3 at https://pr26117-725b4a3.ngbuilds.io/. |
725b4a3
to
fa0ec85
Compare
You can preview fa0ec85 at https://pr26117-fa0ec85.ngbuilds.io/. |
Marking as merge-assistance since:
|
fa0ec85
to
8f522ba
Compare
You can preview 8f522ba at https://pr26117-8f522ba.ngbuilds.io/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This is needed for the TestBed implementation since we can ask for a set of local refs on a given debug element.