rename mutable to makeRepairDataProperties + beMutable to enableDerivedOverride
MODIFY
src/bundle/createSES.js
src/bundle/createSES.js
@@ -24,7 +24,7 @@ import getAllPrimordials from './getAllPrimordials';
import whitelist from './whitelist';
import makeConsole from './make-console';
import makeMakeRequire from './make-require';
-import makeRepairDataProperties from './mutable';
+import makeRepairDataProperties from './makeRepairDataProperties';
const FORWARDED_REALMS_OPTIONS = ['transforms'];

RENAME
src/bundle/mutable.js
src/bundle/makeRepairDataProperties.js
@@ -36,7 +36,7 @@ export default function makeRepairDataProperties() {
* simulate what we should have specified -- that assignments to derived
* objects succeed if otherwise possible.
*/
- function beMutable(obj, prop, desc) {
+ function enableDerivedOverride(obj, prop, desc) {
if ('value' in desc && desc.configurable) {
const { value } = desc;
@@ -77,17 +77,6 @@ export default function makeRepairDataProperties() {
}
}
- function beMutableProperties(obj) {
- if (!obj) {
- return;
- }
- const descs = getOwnPropertyDescriptors(obj);
- if (!descs) {
- return;
- }
- ownKeys(obj).forEach(prop => beMutable(obj, prop, descs[prop]));
- }
-
/**
* These properties are subject to the override mistake
* and must be converted before freezing.
@@ -132,12 +121,26 @@ export default function makeRepairDataProperties() {
];
// Promise may be removed from the whitelist
+ // TODO: the toBeRepaired list should be prepared
+ // externally and provided to repairDataProperties
const PromisePrototype = g.Promise && g.Promise.prototype;
if (PromisePrototype) {
toBeRepaired.push(PromisePrototype);
}
- toBeRepaired.forEach(beMutableProperties);
+ // repair each entry
+ toBeRepaired.forEach(obj => {
+ if (!obj) {
+ return;
+ }
+ const descs = getOwnPropertyDescriptors(obj);
+ if (!descs) {
+ return;
+ }
+ ownKeys(obj).forEach(prop =>
+ enableDerivedOverride(obj, prop, descs[prop]),
+ );
+ });
}
return repairDataProperties;

rename mutable to makeRepairDataProperties + beMutable to enableDerivedOverride