-
-
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
Using observes in child class of Ember.Object breaks Ember Data, eachComputedProperty(), proto() in Firefox #12534
Comments
Could you supply a test/demo where this is actually broken? The behaviour you describe for Firefox is consistent for several Ember versions and I've been extending models in the past and never hit anything like this with Firefox (could have missed it though). As far as I can tell, the way ember-data works with eachComputedProperty, should work as intended. |
Firstly, thanks for reading and replying! Here is another jsbin: http://emberjs.jsbin.com/sunasa/edit?html,js,console,output In that jsbin I am getting the same issue (in Firefox only). Iterating over the attributes of a model created from the store skips over the property with an observer. Is that not happening for you? Putting together a demo that shows the specific context I ran across this is a bit more timeconsuming as I may have to configure adapters and so forth, but I think this demonstrates there is an issue pretty well - there is no way |
Oh my... I think I'm confirming this one. Your second jsbin gives a much clearer example of the issue. In this example I can confirm the following in Firefox:
While potentially breaking ember-data implementations, you are right the problem goes much deeper. To me it seems it definitely breaks eachComputedProperty but since it also affects regular attributes on some level (as shown in your first jsbin), who knows what else might "not work as expected". I'm not sure I'm experienced enough with Ember to debug this, although I'm very curious so I might even try. In the mean time, I'd suggest rewording your issue. I think removing the "Nasty deep bug" part would help to be taken more seriously. |
Glad that it wasn't just me going crazy! It is quite worrying - I was staggered when I first switched to Firefox and realised that half my models no longer existed! Haha, thanks for the advice on title - any suggestions on making it look a bit more serious? I'm not very experienced in issue reporting... |
Oh, and as I mentioned in the first post, it seems to be caused by the observer setup that happens in the |
Using the docs you provided, here is a VERY DIRTY workaround if you require an immediate fix for Firefox: http://emberjs.jsbin.com/qatanud/edit?html,js,console,output I believe the bug itself is the creation of the (mandatory) getters and setters during the extend of the class, where the computed property is not correctly recognized as a descriptor. |
Ah good work, thanks. I have already had to refactor my code in the more obvious breaking places to copy definitions into the child-most class but I could well have missed some so it is good to have a temporary hack to cover those situations. Just by the way, |
Today I found some time to look into this issue. Checked out master and wrote a test. I was very confused when my test succeeded with Firefox. It's already fixed: #12314 |
Ah well good! Thanks for looking into it - I should have tried the canary build in the jsbin. I am still a bit uncertain though, because the first jsbin I posted still fails so there is clearly still something weird going on. However, I'm not sure at this point if that affects any public facing apis, but if I find anything I'll open up another issue for it with. |
JS BIN: http://emberjs.jsbin.com/qiweyu/edit?html,js,output
Breaks in eg Firefox 40 on Ubuntu 14.04, Windows 7, Windows 8.1
Works in eg Chrome on Ubuntu, IE9 on Windows 7
Setup is simple: create an Ember Object with some properties.
Create a child class that extends this object and that defines an observer
Try to iterate over the properties in Bar in the same way as
eachComputedProperty
does (via_computedProperties
)and
firstName
has disappeared!Bizarrely,
console.log(props)
still showsfirstName
as being there, but the iterator seems to be skipping it.Why this is a massively breaking issue
Ember Data uses
eachComputedProperty
as part of pushing data into models. This method does not fire for any properties with the bug above. This means Ember Data just silently ignores whatever is in the payload and produces a model without any data for, eg.,firstName
.In turn this effectively means that the entire user interface of my application is broken wherever this pattern above occurs.
Options
Docs should state that .observes can only be used for properties in the same class, or some fix for Firefox needs to be found. I have no ideas at all why Firefox is breaking here - I have dug enough into Ember to know that if you block
replaceObserversAndListeners
ember.js/packages/ember-metal/lib/mixin.js
Line 351 in 0f5c7f5
The text was updated successfully, but these errors were encountered: