Skip to content

Commit

Permalink
Fixed a regression for multiple __self & __source props with classic …
Browse files Browse the repository at this point in the history
…runtime
  • Loading branch information
Andarist committed Dec 10, 2020
1 parent 4f3fcf1 commit da01efe
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
Expand Up @@ -862,18 +862,15 @@ 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 =
t.isJSXAttribute(attr) &&
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)) {
Expand Down
@@ -0,0 +1 @@
<div/>
@@ -0,0 +1,3 @@
module.exports = () => ({
presets: [["@babel/preset-react", { development: true }]],
});
@@ -0,0 +1,3 @@
{
"presets": [["@babel/preset-react", { "development": true }], "./my-preset"]
}
@@ -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
}
});

0 comments on commit da01efe

Please sign in to comment.