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: Refactor. Mention accessor descriptors. Created Nov. 5, 2017, 2:24 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);
kzar 2017/11/06 08:52:01 How about this (untested): let descriptor = Objec
Oleksandr 2017/11/06 09:05:00 This doesn't work, because some descriptors can be
kzar 2017/11/06 10:12:38 Which APIs are returned using a getter? I find it
Oleksandr 2017/11/06 10:14:18 For example `setUnintstallUrl`, as it says on the
kzar 2017/11/06 10:37:37 Ah right, well you could just delete the getter an
Oleksandr 2017/11/08 13:58:09 I guess we'll just have to see. I don't know why t
kzar 2017/11/10 14:18:20 What do you think about that Manish?
+ // 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 = (...args) =>
Manish Jethani 2017/11/05 10:13:52 Functions and arrow functions have different seman
kzar 2017/11/06 08:52:01 Agreed
Oleksandr 2017/11/06 09:05:00 Done.
{
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