Merge pull request #2428 from jgoz/fix-actions-undefined-descriptor

[addon-actions] Check result of getPropertyDescriptor for IE11
This commit is contained in:
Filipp Riabchun 2017-12-05 12:40:57 +03:00 committed by GitHub
commit 267b90a882
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,8 +24,10 @@ export function action(name) {
});
};
// IE11 may return an undefined descriptor, but it supports Function#name
const nameDescriptor = Object.getOwnPropertyDescriptor(handler, 'name');
// This condition is true in modern browsers that implement Function#name properly
const canConfigureName = Object.getOwnPropertyDescriptor(handler, 'name').configurable;
const canConfigureName = !nameDescriptor || nameDescriptor.configurable;
if (canConfigureName && name && typeof name === 'string') {
Object.defineProperty(handler, 'name', { value: name });