Allow multiple __self/__source props with classic JSX runtime (#12475)

This commit is contained in:
Mateusz Burzyński 2020-12-10 18:17:20 +01:00 committed by GitHub
parent e8176de528
commit 1ef9e196d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 5 deletions

View File

@ -862,7 +862,6 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,
let props = [];
const objs = [];
const found = Object.create(null);
for (const attr of attribs) {
const name =
@ -870,10 +869,8 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,
t.isJSXIdentifier(attr.name) &&
attr.name.name;
if (name === "__source" || name === "__self") {
if (found[name]) throw sourceSelfError(path, name);
found[name] = true;
if (!options.development) continue;
if (!options.development && (name === "__source" || name === "__self")) {
continue;
}
if (useSpread || !t.isJSXSpreadAttribute(attr)) {

View File

@ -0,0 +1,3 @@
module.exports = () => ({
presets: [["@babel/preset-react", { development: true }]],
});

View File

@ -0,0 +1,4 @@
{
"presets": [["@babel/preset-react", { "development": true }], "./my-preset"],
"os": ["linux", "darwin"]
}

View File

@ -0,0 +1,18 @@
var _jsxFileName = "<CWD>/packages/babel-preset-react/test/fixtures/regression/runtime-classic-allow-multiple-source-self/input.mjs",
_jsxFileName2 = "<CWD>/packages/babel-preset-react/test/fixtures/regression/runtime-classic-allow-multiple-source-self/input.mjs";
/*#__PURE__*/
React.createElement("div", {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 1,
columnNumber: 1
},
__self: this,
__source: {
fileName: _jsxFileName2,
lineNumber: 1,
columnNumber: 1
}
});