From 2e4b6c115aa207afb96637ca45ef9b4507b192b7 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Sat, 9 May 2020 20:50:00 +0200 Subject: [PATCH] =?UTF-8?q?Update=C2=A0legacy=C2=A0platform=C2=A0object=20?= =?UTF-8?q?[[Set]]=C2=A0operation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "side effect" part never seemed to be necessary, while heycam/webidl@059491b4de91fdc45d26d simplified the conditions further. --- lib/constructs/interface.js | 46 ++++++++------------ test/__snapshots__/test.js.snap | 76 +++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/lib/constructs/interface.js b/lib/constructs/interface.js index 7285a5ed..d7f305cf 100644 --- a/lib/constructs/interface.js +++ b/lib/constructs/interface.js @@ -841,7 +841,9 @@ class Interface { if (typeof P === "symbol") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { `; if (this.needsPerGlobalProxyHandler) { @@ -850,35 +852,21 @@ class Interface { `; } - if (this.supportsIndexedProperties) { - if (hasIndexedSetter) { - this.str += ` - if (utils.isArrayIndexPropName(P)) { - ${invokeIndexedSetter("target", "P", "V")} - return true; - } - `; - } else { - // Side-effects - this.str += ` - utils.isArrayIndexPropName(P); - `; - } + if (this.supportsIndexedProperties && hasIndexedSetter) { + this.str += ` + if (utils.isArrayIndexPropName(P)) { + ${invokeIndexedSetter("target", "P", "V")} + return true; + } + `; } - if (this.supportsNamedProperties) { - if (hasNamedSetter) { - this.str += ` - if (typeof P === "string" && !utils.isArrayIndexPropName(P)) { - ${invokeNamedSetter("target", "P", "V")} - return true; - } - `; - } else { - // Side-effects - this.str += ` - typeof P === "string" && !utils.isArrayIndexPropName(P); - `; - } + if (this.supportsNamedProperties && hasNamedSetter) { + this.str += ` + if (typeof P === "string") { + ${invokeNamedSetter("target", "P", "V")} + return true; + } + `; } this.str += ` diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap index 6e468a63..561f54ce 100644 --- a/test/__snapshots__/test.js.snap +++ b/test/__snapshots__/test.js.snap @@ -740,10 +740,12 @@ class ProxyHandler { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { const globalObject = this._globalObject; - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + if (typeof P === \\"string\\") { let namedValue = V; namedValue = conversions[\\"DOMString\\"](namedValue, { @@ -2970,8 +2972,10 @@ const proxyHandler = { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + if (typeof P === \\"string\\") { let namedValue = V; namedValue = conversions[\\"DOMString\\"](namedValue, { @@ -5260,8 +5264,10 @@ const proxyHandler = { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + if (typeof P === \\"string\\") { let namedValue = V; namedValue = conversions[\\"DOMString\\"](namedValue, { @@ -7168,8 +7174,9 @@ const proxyHandler = { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { - utils.isArrayIndexPropName(P); + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { } let ownDesc; @@ -7998,10 +8005,9 @@ const proxyHandler = { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { - utils.isArrayIndexPropName(P); - - typeof P === \\"string\\" && !utils.isArrayIndexPropName(P); + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { } let ownDesc; @@ -8312,10 +8318,10 @@ const proxyHandler = { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { - utils.isArrayIndexPropName(P); - - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + if (typeof P === \\"string\\") { let namedValue = V; namedValue = URL.convert(namedValue, { @@ -9811,10 +9817,12 @@ class ProxyHandler { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { const globalObject = this._globalObject; - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + if (typeof P === \\"string\\") { let namedValue = V; namedValue = conversions[\\"DOMString\\"](namedValue, { @@ -12025,8 +12033,10 @@ const proxyHandler = { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + if (typeof P === \\"string\\") { let namedValue = V; namedValue = conversions[\\"DOMString\\"](namedValue, { @@ -14300,8 +14310,10 @@ const proxyHandler = { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + if (typeof P === \\"string\\") { let namedValue = V; namedValue = conversions[\\"DOMString\\"](namedValue, { @@ -16208,8 +16220,9 @@ const proxyHandler = { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { - utils.isArrayIndexPropName(P); + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { } let ownDesc; @@ -17038,10 +17051,9 @@ const proxyHandler = { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { - utils.isArrayIndexPropName(P); - - typeof P === \\"string\\" && !utils.isArrayIndexPropName(P); + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { } let ownDesc; @@ -17352,10 +17364,10 @@ const proxyHandler = { if (typeof P === \\"symbol\\") { return Reflect.set(target, P, V, receiver); } - if (target === receiver) { - utils.isArrayIndexPropName(P); - - if (typeof P === \\"string\\" && !utils.isArrayIndexPropName(P)) { + // The \`receiver\` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas \`target\` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + if (typeof P === \\"string\\") { let namedValue = V; namedValue = URL.convert(namedValue, {