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

Enumerability not a problem #1

Closed
cshaa opened this issue Feb 6, 2015 · 4 comments
Closed

Enumerability not a problem #1

cshaa opened this issue Feb 6, 2015 · 4 comments
Assignees

Comments

@cshaa
Copy link

cshaa commented Feb 6, 2015

When a property is created using Object.defineProperty and set to not enumerable, it's basically invisible to the polyfill (...) There's no way to prevent this limitation.

And what about Object.getOwnPropertyNames? This one returns all (even non-enumerable) properties.

Great work though, I'll probably use it in my app :)

@MaxArt2501
Copy link
Owner

Yes, Object.getOwnPropertyNames would help, but that would solve just a part of a bigger problem.
The main point here is that I'd like to get the most consistent behavior among environments, and there's already the big issue of those browsers that don't support Object.keys - which is what I use to get the property names, and can be "sort of" polyfilled.

But the polyfill still fails big time in some cases, so in the end I might end up using Object.getOwnPropertyNames anyway. That would bring everything closer to Object.observe in browsers that support it - and actually solve the issue you quoted.
Developers that want to support IE8- should be careful about the objects they want to observe, then. Using POJOs would be the safest bet.

As you may notice, getting the names of the properties is one of the biggest challenges of polyfilling Object.observe...

@MaxArt2501 MaxArt2501 self-assigned this Feb 6, 2015
@cshaa
Copy link
Author

cshaa commented Feb 8, 2015

I don't think there's a real need to support IE8 anymore – according to StatCounter, only 3.7% of users worldwide use it. MDN has a Object.keys polyfill that should work even in IE7 but I don't see how could it help as it returns only enumerable props.

@MaxArt2501
Copy link
Owner

Yes, indeed, getting non enumerable properties is basically impossible without the right tools. That's the whole point of the matter.

Every web developer would like to ditch IE8 support with great joy, but sadly companies tend to support the widest range of browsers possible, because 3.7% of users with a bad experience with their sites potentially means 3.7% of customers less. In China there's "a lot" (1.55%) of people still using IE6...

So I won't forget IE8 support for this polyfill (for now), but I'm ok to support if with a few caveats - not everything can be shimmed, after all. Giving support to most of the features is alright in most cases, and that could be fine.

In the end, I decided that I'll swap to Object.getOwnPropertyNames in the next release (that I'll publish in the near future), keeping the current alternative for browsers that don't support it, which is a simplified version of the Object.keys polyfill you linked.

Thank you for the cue, it helped me to take a decision on the matter.

@cshaa
Copy link
Author

cshaa commented Feb 8, 2015

Great! Looking forward :)

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