Skip to content

Commit

Permalink
Update legacy platform object [[Set]] operation
Browse files Browse the repository at this point in the history
The "side effect" part never seemed to be necessary, while
whatwg/webidl@059491b4de91fdc45d26d simplified the conditions further.
  • Loading branch information
ExE-Boss authored May 13, 2020
1 parent 21a948e commit ed3e991
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 61 deletions.
46 changes: 17 additions & 29 deletions lib/constructs/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 += `
Expand Down
76 changes: 44 additions & 32 deletions test/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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, {
Expand Down

0 comments on commit ed3e991

Please sign in to comment.