Skip to content
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

Incompatible with Object.create(null) #76

Closed
tad-lispy opened this issue Nov 3, 2015 · 1 comment
Closed

Incompatible with Object.create(null) #76

tad-lispy opened this issue Nov 3, 2015 · 1 comment

Comments

@tad-lispy
Copy link
Contributor

Hello. Thanks for seamless. It's a very nice piece of software.

I was surprised however that I cannot create immutable object from an object without prototype (e.g. acquired with Object.create(null):

Immutable(Object.create(null));
// TypeError: target.hasOwnProperty is not a function

It is also impossible to merge such an object into immutable:

var o1 = Immutable({a: 1});
var o2 = Object.create(null);
o2.b = 2;
o1.merge(o2);
// TypeError: other.hasOwnProperty is not a function

Obviously it depends on hasOwnProperty method of the original object, which is usually available in a prototype chain.

Can we use global Object methods instead, like Object.getOwnPropertyDescriptor? I'll be happy to provide PR, but would like to discuss it first.

@rtfeldman
Copy link
Owner

I'm surprised by this too! Assuming it wouldn't have noticeable performance costs, I'd be happy to accept a PR that fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants