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
fix(core): Access injected parent values using SkipSelf #39464
Conversation
16ae2ad
to
7a80a16
Compare
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.
Great work @jessicajaniuk 👍 I've left a few comments.
9720620
to
c88b046
Compare
f54a2fc
to
7d0ddaa
Compare
7d0ddaa
to
bcdce27
Compare
f460802
to
14fe03f
Compare
71471fe
to
d5abfdf
Compare
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.
Love all those new tests! Just left a few drive-by comments that you can ignore if you wish.
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.
There is a typo in the commit message, which mentions SelfSkip
instead of SkipSelf
.
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
760b6b1
to
6a6c475
Compare
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
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.
Reviewed-for: size-tracking
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.
Reviewed-for: size-tracking
In ViewEngine, SelfSkip would navigate up the tree to get tokens from the parent node, skipping the child. This restores that functionality in Ivy. In ViewEngine, if a special token (e.g. ElementRef) was not found in the NodeInjector tree, the ModuleInjector was also used to lookup that token. While special tokens like ElementRef make sense only in a context of a NodeInjector, we preserved ViewEngine logic for now to avoid breaking changes. We identified 4 scenarios related to @SkipSelf and special tokens where ViewEngine behavior was incorrect and is likely due to bugs. In Ivy this is implemented to provide a more intuitive API. The list of scenarios can be found below. 1. When Injector is used in combination with @host and @SkipSelf on the first Component within a module and the injector is defined in the module, ViewEngine will get the injector from the module. In Ivy, it does not do this and throws instead. 2. When retrieving a @ViewContainerRef while @SkipSelf and @host are present, in ViewEngine, it throws an exception. In Ivy it returns the host ViewContainerRef. 3. When retrieving a @ViewContainerRef on an embedded view and @SkipSelf is present, in ViewEngine, the ref is null. In Ivy it returns the parent ViewContainerRef. 4. When utilizing viewProviders and providers, a child component that is nested within a parent component that has @SkipSelf on a viewProvider value, if that provider is provided by the parent component's viewProviders and providers, ViewEngine will return that parent's viewProviders value, which violates how viewProviders' visibility should work. In Ivy, it retrieves the value from providers, as it should. These discrepancies all behave as they should in Ivy and are likely bugs in ViewEngine. PR Close #39464
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. |
In ViewEngine, SelfSkip would navigate up the tree to get tokens from
the parent node, skipping the child. This restores that functionality in
Ivy. In ViewEngine, if a special token (e.g. ElementRef) was not found
in the NodeInjector tree, the ModuleInjector was also used to lookup
that token. While special tokens like ElementRef make sense only in a
context of a NodeInjector, we preserved ViewEngine logic for now to
avoid breaking changes.
We identified 4 scenarios related to @SkipSelf and special tokens where
ViewEngine behavior was incorrect and is likely due to bugs. In Ivy this is
implemented to provide a more intuitive API. The list of scenarios can be
found below.
When
Injector
is used in combination with@Host
and@SkipSelf
on the first Component within a module and the injector is defined in the
module, ViewEngine will get the injector from the module. In Ivy, it does
not do this and throws instead. Test
When retrieving a
@ViewContainerRef
while@SkipSelf
and@Host
are present, in ViewEngine, it throws an exception. In Ivy it returns the host
ViewContainerRef
. TestWhen retrieving a
@ViewContainerRef
on an embedded view and@SkipSelf
is present, in ViewEngine, the ref is null. In Ivy it returns theparent
ViewContainerRef
. TestWhen utilizing
viewProviders
andprovider
s, a child component that isnested within a parent component that has
@SkipSelf
on aviewProvider
value, if that provider is provided by the parent component's
viewProviders
and
providers
, ViewEngine will return that parent'sviewProviders
value,which violates how viewProviders' visibility should work. In Ivy, it retrieves
the value from
providers
, as it should. TestThese discrepancies all behave as they should in Ivy and are likely bugs in
ViewEngine.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently Ivy ignores @SkipSelf entirely, which deviates from ViewEngine and expectations of behavior.
Issue Number: 34066, 34819
What is the new behavior?
@SkipSelf now properly navigates up the view tree to find the correct injected resource in the parents.
Does this PR introduce a breaking change?
Closes #34066, #34819.