Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: polyfill.js

Issue 29590603: Issue 5954 - Read-only properties cannot be assigned in strict mode in Edge (Closed)
Patch Set: Use function instead of arrow function. Created Nov. 6, 2017, 9:01 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: polyfill.js
===================================================================
--- a/polyfill.js
+++ b/polyfill.js
@@ -69,8 +69,15 @@
let func = object[name];
if (!func)
return;
-
- object[name] = function(...args)
+ let oldDescriptor = Object.getOwnPropertyDescriptor(object, name);
+ // Some descriptors like setUninstallURL are in fact accessor descriptors.
+ // We convert them to data descriptors.
+ let descriptor = {
+ enumerable: oldDescriptor.enumerable,
+ configurable: oldDescriptor.configurable,
+ writable: oldDescriptor.writable
+ };
+ descriptor.value = function(...args)
{
let callStack = new Error().stack;
@@ -111,6 +118,7 @@
});
});
};
+ Object.defineProperty(object, name, descriptor);
}
function shouldWrapAPIs()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld