-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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(ivy): wrong context passed to ngOnDestroy when resolved multiple times #35249
Conversation
04e0ff9
to
a751fdb
Compare
diPublicInInjector( | ||
getOrCreateNodeInjectorForNode( | ||
tNode as TElementNode | TContainerNode | TElementContainerNode, lView), | ||
tView, token); | ||
if (providerIsTypeProvider || isClassProvider(provider)) { | ||
const prototype = ((provider as ClassProvider).useClass || provider).prototype; | ||
const ngOnDestroy = prototype.ngOnDestroy; |
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 with useFactory
for example when you provide some object which is not a class instance?
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'm not sure about that one, but I'll bring it up. The previous approach didn't support useFactory
either.
@crisbeto yeah, you are right. That would also explain why I always call Thank you for your PR. Please, consider also my concerns in it. |
a751fdb
to
838c435
Compare
This fix is really needed @pkozlowski-opensource |
@pkozlowski-opensource could you... :) |
…times When the same provider is resolved multiple times on the same node, the first invocation had the correct context, but all subsequent ones were incorrect because we were registering the hook multiple times under different indexes in `destroyHooks`. Fixes angular#35167.
838c435
to
ef9d888
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.
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. |
When the same provider is resolved multiple times on the same node, the first invocation had the correct context, but all subsequent ones were incorrect because we were registering the hook multiple times under different indexes in
destroyHooks
.Fixes #35167.