-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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] allow watching of ES5+ Getter #12491
[BUGFIX beta] allow watching of ES5+ Getter #12491
Conversation
Looks great! Can you add a test to https://github.com/emberjs/ember.js/blob/master/packages/ember-metal/tests/accessors/mandatory_setters_test.js also? I think this should likely be bug fix beta to allow for our normal beta testing cycle. |
This is breaking things in dev mode, and doesn't do anything radical to solve the issues. That being said, it may not be a critical fix on-our end. @bmac is it alright if ember-data doesn't get this solution till 2.2? |
23d42e3
to
7b5de09
Compare
Yup, I understand that the bug exists in previously released versions (not just beta). Unless things are fundamentally broken in the wild (which would likely result in a large uproar) we should err on the side of using the normal beta process. This change is deep in the internals and a mistake in this area has the ability to cause massive issues that we may not be able to predict (we have had a number of [BUGFIX release] changes come back to bite us in the backside). Thankfully, this is exactly why we have a beta cycle. |
7b5de09
to
0b8814f
Compare
|
@stefanpenner this functionality is not critical for Ember Data. We shipped a work around for this issue in 2.1 so we can refactor the workaround away in a future release when Ember's support improves. |
e7c98e5
to
5c81e5e
Compare
@bmac I think this addresses everything I could think of, if you have time to confirm on your end that would be good. –––– Turned out, as I worked on this I realized many other things were funky. I suspect this code can continue to be improved. @rwjblue r? |
|
So many new tests 👏 |
Test failures seem related to phantom, will investigate soon |
@@ -38,6 +41,16 @@ export function DEFAULT_GETTER_FUNCTION(name) { | |||
}; | |||
} | |||
|
|||
export function INHERITING_GETTER_FUNCTION(name) { | |||
function IGETTER_FUNCTION() { | |||
var proto = Object.getPrototypeOf(this); |
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.
It seems to me (just off the bat) that we need to do the same thing as was added in #12314 to lookup the getter through the entire prototype chain. As it exists here, I believe that a getter from a parent class will not be found.
Specifically, I think we should use lookupDescriptor, and add some tests around this behavior like these ones only for getter.
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 don't think so, this exists to simulate the behavior if no descriptor existed at this level. It aims to re-target get one step up the prototype chain.
In-case i mis-understood, here are the relevant tests (which may explain better when this aims to do then I can), -> Related tests->: https://github.com/emberjs/ember.js/pull/12491/files#diff-25946da80206a01a2f680ad806bb1780R370
Let me know if im not crazy.
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.
wait i believe i see it now.
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.
adding another test
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.
Added a test, will investigate another time (time for bed)
5c81e5e
to
48b5298
Compare
After chatting with kris, he had a good idea, installing the mandatory setter for inherited properties in at the level defined (instead of at the leaf). Will explore this. |
Before this commit MandatorySetter enabled + current property being watched resulted in `get` always fetching via meta.values. Although this typically works, the default getter for a MandatorySetter already does this, so it is actually redundant. Going further, when a user defines their own getter this code-path is incorrectly taken, instead the original value (which originated from the getter) should be the consulted value
48b5298
to
7daec5c
Compare
* no longer rely on meta to store the value until next set after uninstalling MandatorySetter * no longer incorrectly re-set on set to enumerable (enumerability should remain constant) * test both enumerable / non-enumerable variants
f12c519
to
3a522ca
Compare
3a522ca
to
4c048be
Compare
I don't believe the IE9 failure is critical, but I will investigate it once I have IE9 handy. It appears to just be a IE9ism, and very specific tests one my part. I just need to go with IE9 and see how it handles this edge case and update the tests accordingly. |
4c048be
to
4e052ff
Compare
IE9 issue is fixed in my VM, lets see what sauce thinks. |
It is worth noting, this will make development builds of ember run slower (but will leave prod builds the same). Unfortunately short of either taking a drastically different approach, or disabling mandatory setter entirely, I'm unsure of another approach. It is possible for us to explore micro-related improvements, but... |
[BUGFIX beta] allow watching of ES5+ Getter
Following this TODO: emberjs#12491 (comment)
Before this commit MandatorySetter enabled + current property being watched
resulted in
get
always fetching via meta.values. Although this typically works,the default getter for a MandatorySetter already does this, so it is actually redundant.
Going further, when a user defines their own getter this code-path is incorrectly taken,
instead the original value (which originated from the getter) should be the consulted value.
This is blocking an ember-data fix, and likely causing grief for users who use ES5 getter/setters mixed in with our templates.
cc @krisselden