Ember.A seems to modify array instance
See original GitHub issueWe’re seeing a bug in the Ember Simple Auth dummy app (simplabs/ember-simple-auth#1260) that seems to be caused by the fact that ~Enumerable.uniq~Ember.A
tries to modify the provided array. This only seems to affect addon projects where prototype extension is disabled (this is mostly an assumption for now though).
Reproduction steps:
var array = ['a', 'a'];
Object.freeze(array);
Ember.A(array);
// =>
ember.debug.js:21542 Uncaught TypeError: Cannot add property nextObject, object is not extensible
at Object.defineProperty (ember.debug.js:21542)
at applyMixin (ember.debug.js:20576)
at MixinPrototype.apply (ember.debug.js:20770)
at Object.A (ember.debug.js:37397)
at eval (eval at init (query-string.js:35), <anonymous>:1:7)
at Class.init (query-string.js:35)
at new Class (ember.debug.js:36118)
at Function._ClassMixinProps.create (ember.debug.js:36306)
at Class.buildQueryString (oauth2-code.js:110)
at Class.buildUrl (oauth2-code.js:120)
This only seems to fail in addon dummy apps but not in real apps.
/cc @Turbo87
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
ember.js - How do I modify elements in an array that is ...
I make a copy of the array, modify it, and then set it back. But somehow Ember complains about the 4th line, where...
Read more >Ember.Array - 2.14
This mixin implements Observer-friendly Array-like behavior. It is not a concrete implementation, but it can be used up by other classes that want...
Read more >How to Avoid Shared States Between Mixins in Ember.js
As you can see, it looks like they are sharing the same array instance between them, which leads to buggy behavior. This bug...
Read more >Converting Your Ember App to TypeScript - Inside Skylight
PromiseArray makes sense, but I wouldn't expect an array of any values. It should be a more specific type. Something seems wrong here....
Read more >The 8 Most Common Mistakes That Ember.js Developers Make
In this example your component then can be re-used, by just changing the "setaction" to point to a different action for the data...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ya. It’s already mega costly. Copying would also likely break some code that expects the array to be The same.
Work should be done so that Ember.A can be phased out
I guess the fix for actually making it so that the object wasn’t modified at all would be to always clone the object before applying the mixin (if prototype extensions are disabled/the mixin hasn’t already been applied on the prototype) but I guess the performance overhead for that is prohibitive?