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

"Uncaught TypeError: Cannot redefine property: name" on Chrome 41 #7

Closed
raido opened this issue Apr 7, 2019 · 0 comments
Closed

"Uncaught TypeError: Cannot redefine property: name" on Chrome 41 #7

raido opened this issue Apr 7, 2019 · 0 comments

Comments

@raido
Copy link
Contributor

raido commented Apr 7, 2019

It seems Chrome 41 (possibly other older Chrome versions, or other browsers) do not allow Function.name redefinition via Object.defineProperty.

Offending line:

https://github.com/pzuraq/ember-decorators-polyfill/blob/master/vendor/ember-decorators-polyfill/index.js#L275

Minimal reproduction to drop in dev console on Chrome 41:

function a() {}; Object.defineProperty(a, 'name', { value: 'b' }); a.name;

As it says on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name

Note that in non-standard, pre-ES2015 implementations the configurable attribute was false as well.

It seems it would make sense to wrap the Object.defineProperty for name in try catch, as ES2015+ browsers will allow to assign the name and others don't for this anonymous method: https://github.com/pzuraq/ember-decorators-polyfill/blame/master/vendor/ember-decorators-polyfill/index.js#L256

Or drop it all together.

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

No branches or pull requests

1 participant