This repository was archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(compiler): $onDestroy hook not called #11858
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Splaktar
suggested changes
Mar 7, 2020
Contributor
Splaktar
left a comment
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 happy with these changes, but we need some unit tests to cover this functionality.
Splaktar
approved these changes
Apr 27, 2020
Contributor
Splaktar
left a comment
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
Even though the $onInit lifecycle hook is fully supported, the $onDestroy hook isn't. This is unexpected for developers. This change introduces a listener for the $destroy event on the linked scope. See https://docs.angularjs.org/api/ng/type/$rootScope.Scope#event-$destroy This implementation closely resembles the AngularJS internal implementation of the lifecycle hook invokation behavior: https://github.com/angular/angular.js/blob/2b28c540ad7ebf4a9c3a6f108a9cb5b673d3712d/src/ng/compile.js#L3298-L3302 Fixes #11847
jelbourn
approved these changes
Apr 28, 2020
Member
jelbourn
left a comment
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
cla: yes
PR author has signed Google's CLA: https://opensource.google.com/docs/cla/
P3: important
Important issues that really should be fixed when possible.
pr: lgtm
This PR has been approved by the reviewer
pr: merge ready
This PR is ready for a caretaker to review
type: enhancement
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check that your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Even though the
$onInitlifecycle hook is fully supported, the$onDestroyhook isn't. This is unexpected for developers.What is the new behavior?
This change introduces a listener for the
$destroyevent on the linked scope. See https://docs.angularjs.org/api/ng/type/$rootScope.Scope#event-$destroyThis implementation closely resembles the AngularJS internal implementation of the lifecycle hook invokation behavior: https://github.com/angular/angular.js/blob/2b28c540ad7ebf4a9c3a6f108a9cb5b673d3712d/src/ng/compile.js#L3298-L3302
Fixes #11847
Does this PR introduce a breaking change?