Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix legacy platform object [[Set]] operation #218

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
ExE-Boss marked this conversation as resolved.
Show resolved Hide resolved
`;

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