Skip to content
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

[BUGFIX beta] Avoid storing container on the prototype. #15163

Merged
merged 1 commit into from
Apr 24, 2017

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Apr 24, 2017

In order to support this.container (deprecated since 2.3) being available to objects for backwards compatibility, we define the container property on all classes that we instantiate via normal DI APIs.

The bulk of the work to support this was done in prior refactorings. This change is targetted at ensuring that we do not leak the container instance onto the object's prototype in the CONTAINER_OVERRIDE slot.

After these changes, we still support all of the APIs that we supported previously, but will fallback to the current objects owner __container__ property (instead of storing it on the prototype directly).

Also, the test being updated here was not providing the owner to the container in the unit test. This test being changed was previously only doing part of the required setup for creating a registry / container / owner group.

In order to support `this.container` (deprecated since 2.3) being available
to objects for backwards compatibility, we define the `container` property
on all classes that we instantiate via normal DI APIs.

The bulk of the work to support this was done in prior refactorings. This
change is targetted at ensuring that we do not leak the container instance
onto the object's prototype in the `CONTAINER_OVERRIDE` slot.

After these changes, we still support all of the APIs that we supported
previously, but will fallback to the current objects owner `__container__`
property (instead of storing it on the prototype directly).

Also, the test being updated here was not providing the `owner` to the
container in the unit test. This test being changed was previously only
doing part of the required setup for creating a `registry` / `container` /
`owner` group.
let registry = new Registry();
let container = registry.container();
let container = owner.__container__ = registry.container({ owner });
Copy link
Member Author

@rwjblue rwjblue Apr 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - This is exactly what is done in "reality" outside of these unit tests. See EngineInstance code for confirmation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

App instance didn't already have a ref to the container?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never mind, I realize here owner is a stub for a unit test, ignore my comment.

@rwjblue rwjblue merged commit b80407b into emberjs:master Apr 24, 2017
@rwjblue rwjblue deleted the avoid-leaking-container branch April 24, 2017 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants