mootools / mootools-core

MooTools Core Repository
https://mootools.net
2.65k stars 510 forks source link

Object.values less tolerant in 1.5.3 dev vs 1.5.1 #2746

Closed si13b closed 9 years ago

si13b commented 9 years ago

Object values in 1.5.1:

Object.values(null)
=> []

Object values in 1.5.3 dev:

Object.values(null)
=> Uncaught TypeError: Cannot convert undefined or null to object(…)
arian commented 9 years ago

That's because it uses Object.keys now, which internally uses ToObject(o) (for newer browsers at least), which throws for null and undefined.

For MooTools, the behavior of other types of values is not documented, so we don't guarantee the result of Object.values(null).

Looking at the ES2016 proposal for Object.values, it will use ToObject(o) as well, thus throws, so is more or less consisted with MooTools 1.5.2 Object.values

si13b commented 9 years ago

That makes sense and it's probably the preferred behaviour, especially if it's consistent with the (potentially) native implementation. I'm not sure if it's worth flagging this somewhere in the docs or not so users know there's a potentially breaking change when upgrading from 1.5.1?

Feel free to close this one.