Skip to content

Commit

Permalink
fixup! fix: correctly聽transform __proto__聽properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Jan 21, 2021
1 parent 6127a26 commit 0357fe1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
@@ -0,0 +1,11 @@
var shorthand = {
__proto__,
}

var method = {
__proto__() {}
}

var methodComputed = {
["__proto__"]() {}
}
@@ -0,0 +1,7 @@
{
"plugins": [
"external-helpers",
"transform-computed-properties",
"transform-shorthand-properties"
]
}
@@ -0,0 +1,3 @@
var shorthand = babelHelpers.defineProperty({}, "__proto__", __proto__);
var method = babelHelpers.defineProperty({}, "__proto__", function () {});
var methodComputed = babelHelpers.defineProperty({}, "__proto__", function () {});
Expand Up @@ -29,12 +29,14 @@ export default declare(api => {
}
},

ObjectProperty({ node }) {
ObjectProperty(path) {
const { node } = path;
if (node.shorthand) {
node.shorthand = false;
if (t.isIdentifier(node.key, { name: "__proto__" })) {
node.key = t.stringLiteral(node.key.name);
node.computed = true;
const computedKey = t.toComputedKey(node);
if (t.isStringLiteral(computedKey, { value: "__proto__" })) {
path.replaceWith(t.objectProperty(computedKey, node.value, true));
} else {
node.shorthand = false;
}
}
},
Expand Down

0 comments on commit 0357fe1

Please sign in to comment.