-
Notifications
You must be signed in to change notification settings - Fork 58
updated lang.isObject to work in ES6 Fixes #62 #63
Conversation
Looking at #45 it might be desirable to exclude array and regexp. Let me know if we want to add this exclusion and I can add
However, it's worth noting that all the tests passed, so we can't be too concerned with it, eh? ;) |
Probably all host objects (RegExp, Date, Promise, ...) should be excluded, since in those aren't things you'd want to copy by simply traversing properties. Also, arrays are not "objects" in this use case. |
Yes... the The intent of fixing that was to come up with a simpler and less brittle solution that we wouldn't just keep playing whack-a-mole with things to exclude, but #62 points out that the current solution still has a caveat. |
First, let's rename this method Starting in ES6 using toString to identify the type as an plain object is no longer an option. The spec states this explicitly:
We can detect if a Symbol has been used:
But we can no longer use I've been through the ES6 spec and haven't found a better way than checking if something is an object and then explicitly blacklisting objects I would not want to copy. |
Ugh, I almost hate that I found this. The spec states:
This requires briefly modifying the original object meaning that if they do If we want to use the method above to address the Symbol.toStringTab corner case we need to find a work-around for a frozen object. Maybe there's an obvious way around this but I've been looking at the ES6 spec long enough that my brain is frozen. I still vote to explicitly blacklist objects we don't want to copy. |
Bleurgh... Should we drop |
It is not (and never was) in My concern has always been 100% related to making it do exactly what we need for the deep assign/mixin functions, but preferably in a way that isn't going to cause us to play a decade-long game of whack-a-mole. That's why I created #45, and we had thought we'd resolved that... until Bryan pointed out #62 (thanks, ES6!). I agree with Paul's idea of renaming the function. |
@kfranqueiro oops... yes, sorry, just noticed that... 😢 and agree with renaming |
Where are we on this PR? |
Looks like the function hasn't been renamed yet (Paul suggested More importantly, the implementation on this branch currently doesn't filter what we need it to, either (e.g. Date objects would return Really, the existing implementation was fine AFAIK except for the Symbol caveat. :/ |
Picking this up... The convention of guards is |
In reviewing this with Mangala again, I am very much in favor of a name such as |
Updated and ran tests against Chrome 44. Tests pass. Coverage reports it was run 25 time, although it's not directly called in tests. Related to #45 Fixes #62