-
-
Notifications
You must be signed in to change notification settings - Fork 893
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.defineProperty does not fail silently in IE8 #297
Comments
See also: #5. |
|
This is likely just an oversight over time since 2011 when it was first written. In IE 8, which provides a half-broken |
Any updates for this issue? |
This is related to #249 as well. No updates yet - pull requests are welcome. The sham provides zero guarantees about its behavior across various browsers, so it doesn't tend to get worked on as quickly, but I'd be happy to review something :-) |
Any workarounds for es5-sham throwing on IE8? |
I can take a stab at it, but I don't necessarily understand the entire rationale behind the current code path. There's some (commented-out) code in there that would handle this use-case, but it would need to move, and I'm not sure why it was originally commented out... |
Hopefully @WebReflection can comment. @schmod The primary concern is that as many browsers as possible have a conforming Please feel free to submit a PR! |
unless I am misreading something, if (('get' in descriptor || 'set' in descriptor) && !supportsAccessors) throw ... But then since IE8 won't be able to update any part of the descriptor in regular objects, I am not sure what should happen at the end ... probably nothing, if silent failure is expected. |
Just to share my experience... I have recently moved away from es5-shim to |
|
There's no need for +1's on this. The question is, when using the As @WebReflection points out in #297 (comment), what would you expect the behavior to be if you're simply attempting to update configurability, writability, or enumerability? Certainly, if it throws, it shouldn't throw an "accessors not supported" error, but a more descriptive one. So, the decision to make here: fix the error message and update the documentation, or remove the error in this case and comply with the documented behavior? |
#315 now makes it so it only throws when accessors aren't supported if you provide "get" or "set". The remaining open question: should https://github.com/yiminghe/es5-shim/blob/definePropertyFix/es5-sham.js#L383-L395 be uncommented (and moved up above the if/else) so that |
I think it makes sense to uncomment those lines, unless there's some weird edge case that we're not thinking of (which caused them to be commented out in the first place). |
@pkese thanks for the tip, I'm running into the same issues with the same setup. However, switching to I guess i'll have to update my app to |
I have the same problem and had to resort to loading es5-sham with a document.write() to make it work. |
@dutchcelt could you please elaborate further on how you got this to work using |
The issue is that I can't possible conceive of any situation where |
Hm. Thinking more about this, uncommenting those lines appears to violate the spirit of the sham. I think it makes sense for us to throw when getters and setters are requested, because there's very little to gain if we fail silently in those places (ie. there's a very high probability that the underlying application will stop working). On the other hand,
However, I think that this is a separate issue. If we can confirm that #315 resolved the original issue, I think that we can close this ticket. Not quite sure what @dutchcelt was encountering, because the behavior documented in my original post appears to have been corrected. |
The documentation for es5-sham seems to imply that
Object.defineProperty()
should fail when setting properties such asconfigurable
,enumerable
, andwritable
.However, running the following code throws an error:
Looking at the relevant portion of the sham, it seems like we almost always throw an error if getters/setters are unsupported (even if we're not asking for a getter or setter):
The above code always throws
ERR_ACCESSORS_NOT_SUPPORTED
instead of silently failing (which is the documented behavior).The text was updated successfully, but these errors were encountered: