Ember.isArray will not detect plain object with length property#12761
Ember.isArray will not detect plain object with length property#12761tragiclifestories wants to merge 1 commit intoemberjs:masterfrom
Conversation
|
I'd say that this is not desired behaviour. An object having a Neither |
|
@cibernox That is what this change is supposed to achieve; the current behaviour of isArray will pass for |
|
Oh, I understood it the other way around. My bad. In that case seems reasoable, but a breaking change in such a basic method is delicate. |
|
Id say that an aray-like object should be any object where |
|
Indeed. I wouldn't have worked on it if the mood music in the issues linked hadn't been of a 'hell with it, go ahead' kind of tone. And yes, it would have been nice to have a Ruby/Python style iterable interface like 10 years ago, but we are where we are ... :-) |
|
We just spotted this rather unexpected behavior - is there any movement on this PR? |
|
@thomblake tbh I'd almost forgotten about it myself. |
|
I'm closing this in favor of the approach taken by #12708. That seems to handle the root cause error, that fileList is considered an |
|
@mixonic Well, I still think this is unexpected behaviour. Eg, say I have a Product class, which has separate size properties for depth, width and length. I would not want ember to assume that instances of this class were iterable. |
|
Yeah we also encountered this in a different context and it was really surprising. |
To fix #12738 and #12688
This is a backwards incompatible change (if someone was relying on this test returning true for an object that happened to have a length property), but the old behaviour is surprising and out of line with native Array.isArray implementations, lodash.isArray and so on.