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

[WIP] Add an assertion when watched props are are written to without Em.set. #9395

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Oct 26, 2014

If a property that is being watched (but was not available on the object at the time the watching was setup) is set directly (without Ember.set), no assertion will be fired and any Ember.get's on that property will return undefined (see explanation). This PR adds an assertion to provide a path forward (basically use Ember.set).

Closes #9387.

This is still a WIP, as it fails a single test that is actually relying on this behavior (setting a plain prop). Would love input on that test to see if it is possible to maintain its intent while refactoring to allow this PR/assertion.

@@ -81,6 +81,10 @@ var get = function get(obj, keyName) {
if (Ember.FEATURES.isEnabled('mandatory-setter')) {
if (hasPropertyAccessors && meta && meta.watching[keyName] > 0) {
ret = meta.values[keyName];

if (ret === undefined && keyName in obj && !(keyName in meta.values)) {
Copy link
Member

Choose a reason for hiding this comment

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

this may be fine, but we should confirm no perf issue is caused by this in.

If there is we can always be clever and use one the sentinel UNDEFINED technique

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, I'll look into that.

Also, this whole section is completely removed from prod builds.

Copy link
Member

Choose a reason for hiding this comment

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

ah ok

@rwjblue
Copy link
Member Author

rwjblue commented Oct 27, 2014

@krisselden - Would love your thoughts on both the issue and possibly how to make the failing test I referenced pass with this change...

@wagenet
Copy link
Member

wagenet commented Nov 1, 2014

@krisselden ping

@rwjblue rwjblue changed the title [WIP] Add a assertion when watched props are are written to without Em.set. [WIP] Add an assertion when watched props are are written to without Em.set. Dec 3, 2014
@rwjblue rwjblue closed this Mar 26, 2015
@rwjblue rwjblue deleted the provide-assertion-when-setting-watched-property branch November 21, 2015 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Observer + Ember.get regression in beta 1.8 + canary
3 participants