Skip to content

Commit

Permalink
Avoid crashing when Function.name is not configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
raido committed Apr 7, 2019
1 parent fbb3ae8 commit d9f2836
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions vendor/ember-decorators-polyfill/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,14 @@ import {
);

if (DEBUG) {
Object.defineProperty(decorator, 'name', {
value: fnName,
});
let desc = Object.getOwnPropertyDescriptor(decorator, 'name');
// Pre ES2015 non standard implementation, "Function.name" is non configurable field
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
if (desc.configurable) {
Object.defineProperty(decorator, 'name', {
value: fnName,
});
}
}

return decorator;
Expand Down

0 comments on commit d9f2836

Please sign in to comment.