-
Notifications
You must be signed in to change notification settings - Fork 27k
fix(core): establish proper defer injector hierarchy for components attached to ApplicationRef #56763
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
…ttached to ApplicationRef This commit updates the logic that create an injector for defer blocks (when it's needed) to account for a situation when a component is instantiated without a connection to the current component tree. This can happen if a component is created using its factory function or via `createComponent()` call. Resolves angular#56372.
0e2b8e5 to
2e0961b
Compare
| // 1. Provided `parentInjector` | ||
| // 2. Newly-created `EnvironmentInjector` with extra providers | ||
| // 3. `EnvironmentInjector` from the `parentInjector` | ||
| if (parentEnvInjector !== parentInjector) { |
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 logic looks reasonable, but I wonder if it's necessary - are there cases where parentInjector is not directly an EnvironmentInjector? I suspect this is more possible in tests than production applications.
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 agree, this is probably very uncommon. As a potential followup we can explore whether we can change the type of lView[INJECTOR] from an Injector (which is also optional) to ChainedInjector|EnvironmentInjector, in which case we can drop this condition as well.
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.
Ideally, we'd have a devmodeassert for the cast that passes TGP...
|
Caretaker note: TGP is "green", this PR is ready for merge. |
…ttached to ApplicationRef (#56763) This commit updates the logic that create an injector for defer blocks (when it's needed) to account for a situation when a component is instantiated without a connection to the current component tree. This can happen if a component is created using its factory function or via `createComponent()` call. Resolves #56372. PR Close #56763
…ttached to ApplicationRef (#56763) This commit updates the logic that create an injector for defer blocks (when it's needed) to account for a situation when a component is instantiated without a connection to the current component tree. This can happen if a component is created using its factory function or via `createComponent()` call. Resolves #56372. PR Close #56763
|
This PR was merged into the repository by commit 00d9cd2. The changes were merged into the following branches: main, 18.0.x, 18.1.x |
|
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 commit updates the logic that create an injector for defer blocks (when it's needed) to account for a situation when a component is instantiated without a connection to the current component tree. This can happen if a component is created using its factory function or via
createComponent()call.Resolves #56372.
PR Type
What kind of change does this PR introduce?
Does this PR introduce a breaking change?