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

Check if property descriptor is configurable before re-defining it #394

Merged
merged 1 commit into from Apr 9, 2016

Conversation

jdelStrother
Copy link
Contributor

Android Browser 4.0 appears to have a non-configurable Error.prototype.name property -

Object.getOwnPropertyDescriptor(Error.prototype, 'name')
// returns - 
{"value":"Error", "writable": false, "enumerable": false, "configurable": false}

and will raise a (confusingly-name) "Cannot redefine property: defineProperty" error if you try to re-define Error.prototype.name.

How about checking for desc.configurable before attempting to call Object.defineProperty ?

This fixes #373

Android Browser 4.0 has a non-configurable Error.prototype.name property
@ljharb
Copy link
Member

ljharb commented Apr 8, 2016

Hmm - while I think this is a good fix, that property descriptor says it's not enumerable. What does Object.prototype.propertyIsEnumerable.call(Error.prototype, 'name') say on Android Browser 4.0?

@jdelStrother
Copy link
Contributor Author

Ugh, sorry - I've been limited to debugging this via lots of alert()s, and had to manually copy that message across - I must have typoed it. The real value is :

Object.getOwnPropertyDescriptor(Error.prototype, 'name')
// returns - 
{"value":"Error", "writable": false, "enumerable": true, "configurable": false}

(and FWIW, yes, Object.prototype.propertyIsEnumerable.call(Error.prototype, 'name') returns true)

@ljharb
Copy link
Member

ljharb commented Apr 8, 2016

Phew, ok, at least they're consistent :-D That would be far worse. Thanks!

I'll merge and release this as soon as I can verify it on Browserstack - hopefully later today, or if not, tomorrow.

@ljharb ljharb merged commit a874e4a into es-shims:master Apr 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kindle Fire HD 8.9: Uncaught TypeError: Cannot redefine property: defineProperty
2 participants