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

Added support for dynamic properties in classes #285

Closed
wants to merge 1 commit into from

Conversation

ntninja
Copy link

@ntninja ntninja commented Jan 10, 2015

Important: Dynamic property support only works with IE>=9! That however is not a problem because prototype will fall back to static property copying on older versions. IE8 has limited support for dynamic properties but only if the element is an instance of a DOM element and if a very specifc configuration is used (http://msdn.microsoft.com/en-us/library/dd229916%28VS.85%29.aspx). Since the IE8 support is not something that works in real-life I decided to add a IS_DEFPROP_BUGGY check that only passes on browsers with full support, before enabling this feature.

A unit test has been added that demonstrates how this feature can be used, note however that the unit test only uses the Object.defineProperty syntax and not the native get x() {...}/set x(y) {...} syntax since that would cause syntax errors in browsers that do not understand it.

@savetheclocktower
Copy link
Collaborator

I'm having trouble seeing how this would be used and how we could properly document it. Plus we're not fond of adding features that only work on certain browsers, particularly if the user has to do a capability check in their own code before they know whether it's safe to use that feature.

Feel free to re-open this if I've misunderstood any of the above.

@ntninja
Copy link
Author

ntninja commented May 5, 2015

If I (as a developer) create an object utilizing properties, then I will either (hopefully) know that my code won't be able to run on older browser versions (particularly IE<9) at all (whether prototype supports it or not is not relevant in this case) or I won't care. Where prototype's support does matter is when I've made the decision for this compatibility trade-off (to not support IE<9), but want to use prototype's Class.create to manage my (property-enabled) classes.

About communicating this to library users: I think this change hardly deserves more than a changelog footnote; if a browsers properly supports properties, so will prototype, if it doesn't, then prototype won't either.

@ntninja
Copy link
Author

ntninja commented May 5, 2015

PS: I can't reopen

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

Successfully merging this pull request may close these issues.

None yet

2 participants