-
-
Notifications
You must be signed in to change notification settings - Fork 892
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
Object.defineProperties(obj, { constructor: .. }} broken in IE8 #252
Comments
IE 8 doesn't support property definitions in any way - you'll note that Please read the readme for the caveats on the es5-sham methods. |
I'm familiar with the sham principle and best-effort attempt it does. In the library this is for we make a principle to (at the moment) only use ES5 features that can be relatively easily functionally polyfilled back to IE7. We don't use property descriptors with getters/setters, and no Property descriptors don't matter much as they're deterministic in other browsers (like strict mode). If the application depends on it, one is probably doing it wrong. It's more to get better feedback during development to avoid doing something you didn't intend. Having it just set the property value in older browsers seems perfectly possible. And is in fact what I think it's reasonable to aim for consistency within the sham. Either decide property descriptors should be ignored always or used always. Or maybe only when they have a |
Figured out why it wasn't working. In old IE, the DontEum / enumerable:false behaviour of a property is infectious and overrides it in any objects that inherits the object where such property exists. Thus, a plain object like See also: |
The fix for it has already been implemented in |
If you can provide a test case, I'll be happy to fix/accept a PR fixing the sham. Whether it's reasonable or not to be able to ignore descriptors is a decision for each library, and a very subjective one - the ES shims' position on this is that if it doesn't work 100% or 0% in all browsers, it must not be in the shim. |
In IE8 the 'constructor' property was not being defined by the Object.defineProperties method of the sham because IE8 does not enumerate the constructor property.
IE8 - Fix #252 'constructor' in Object.defineProperties
Properties other than
constructor
seem to work fine. And when usingObject.defineProperty
directly it works fine as well.I ran into this when using
Object.create
to set up a subclass prototype and restoring theconstructor
property afterwards:In modern browsers (e.g. latest Chrome) without the es5-shim,
targetFn.prototype.constructor === targetConstructor
. But in IE8 the defineProperties call was a no-op.The text was updated successfully, but these errors were encountered: