-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX lts] Ensure
destroy
methods on CoreObject
are invoked.
When an instance of `CoreObject` is destroyed with `@ember/destroyable` (or the polyfill when using Ember 3.20+), the instances own `destroy` method is never called. In _general_ "this is fine" because the majority of consumers are using `willDestroy` for their custom object teardown needs. Unfortunately, this isn't _quite_ good enough and any consumers that are directly relying on extending from `CoreObject` and having a custom `destroy` method called will no longer function. The prime example of this is the `Owner` instance itself. Currently, running `destroy(owner)` **does not** actually destroy any instantiated objects in the container. This is because `ContainerProxyMixin` implements `destroy` in order to call `this.__container__.destroy()` which is where the actual cleanup happens. That whole system should be refactored to leveraging `@ember/destroyable` system directly, but in the meantime this case (and any others where folks have implemented a destroy method in Mixins or other subclasses of Ember.CoreObject) should **absolutely** be fixed. This fix ensures that any `destroy(someInstance)` calls on a `CoreObject` directly invoke the `destroy` method on the instance in the same manner as Ember < 3.20 (`.destroy()` is called eagerly, before `willDestroy`). (cherry picked from commit 4d55dae)
- Loading branch information
Showing
4 changed files
with
74 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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