babel-plugin-jsx-dom-expressions 0.35.18 → 0.35.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +8 -58
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -428,7 +428,7 @@ function wrappedByText(list, startIndex) {
|
|
|
428
428
|
return false;
|
|
429
429
|
}
|
|
430
430
|
|
|
431
|
-
function transformCondition
|
|
431
|
+
function transformCondition(path, inline, deep) {
|
|
432
432
|
const config = getConfig(path);
|
|
433
433
|
const expr = path.node;
|
|
434
434
|
const memo = registerImportMethod(path, config.memoWrapper);
|
|
@@ -450,10 +450,10 @@ function transformCondition$1(path, inline, deep) {
|
|
|
450
450
|
: path.scope.generateUidIdentifier("_c$");
|
|
451
451
|
expr.test = t__namespace.callExpression(id, []);
|
|
452
452
|
if (t__namespace.isConditionalExpression(expr.consequent) || t__namespace.isLogicalExpression(expr.consequent)) {
|
|
453
|
-
expr.consequent = transformCondition
|
|
453
|
+
expr.consequent = transformCondition(path.get("consequent"), inline, true);
|
|
454
454
|
}
|
|
455
455
|
if (t__namespace.isConditionalExpression(expr.alternate) || t__namespace.isLogicalExpression(expr.alternate)) {
|
|
456
|
-
expr.alternate = transformCondition
|
|
456
|
+
expr.alternate = transformCondition(path.get("alternate"), inline, true);
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
} else if (t__namespace.isLogicalExpression(expr)) {
|
|
@@ -1457,7 +1457,7 @@ function processSpreads$1(path, attributes, { elem, isSVG, hasChildren, wrapCond
|
|
|
1457
1457
|
wrapConditionals &&
|
|
1458
1458
|
(t__namespace.isLogicalExpression(node.value.expression) ||
|
|
1459
1459
|
t__namespace.isConditionalExpression(node.value.expression))
|
|
1460
|
-
? transformCondition
|
|
1460
|
+
? transformCondition(attribute.get("value").get("expression"), true)
|
|
1461
1461
|
: t__namespace.arrowFunctionExpression([], node.value.expression);
|
|
1462
1462
|
runningObject.push(
|
|
1463
1463
|
t__namespace.objectMethod(
|
|
@@ -2310,57 +2310,6 @@ function createElement(path, { topLevel, hydratable }) {
|
|
|
2310
2310
|
if (props.length > 1 || dynamicSpread) {
|
|
2311
2311
|
props = [t__namespace.callExpression(registerImportMethod(path, "mergeProps"), props)];
|
|
2312
2312
|
}
|
|
2313
|
-
|
|
2314
|
-
// transformed = t.arrowFunctionExpression(
|
|
2315
|
-
// [],
|
|
2316
|
-
// t.objectExpression(
|
|
2317
|
-
// attributes.reduce((memo, attribute) => {
|
|
2318
|
-
// const node = attribute.node;
|
|
2319
|
-
|
|
2320
|
-
// if (t.isJSXSpreadAttribute(node)) {
|
|
2321
|
-
// const expr = node.argument;
|
|
2322
|
-
// memo.push(t.spreadElement(expr));
|
|
2323
|
-
// return memo;
|
|
2324
|
-
// }
|
|
2325
|
-
// let value = node.value,
|
|
2326
|
-
// key = t.isJSXNamespacedName(node.name)
|
|
2327
|
-
// ? `${node.name.namespace.name}:${node.name.name.name}`
|
|
2328
|
-
// : node.name.name,
|
|
2329
|
-
// reservedNameSpace =
|
|
2330
|
-
// t.isJSXNamespacedName(node.name) && reservedNameSpaces.has(node.name.namespace.name);
|
|
2331
|
-
// if (
|
|
2332
|
-
// ((t.isJSXNamespacedName(node.name) && reservedNameSpace) || ChildProperties.has(key)) &&
|
|
2333
|
-
// !t.isJSXExpressionContainer(value)
|
|
2334
|
-
// ) {
|
|
2335
|
-
// node.value = value = t.JSXExpressionContainer(value || t.JSXEmptyExpression());
|
|
2336
|
-
// }
|
|
2337
|
-
|
|
2338
|
-
// if (
|
|
2339
|
-
// t.isJSXExpressionContainer(value) &&
|
|
2340
|
-
// (reservedNameSpace ||
|
|
2341
|
-
// ChildProperties.has(key) ||
|
|
2342
|
-
// !(t.isStringLiteral(value.expression) || t.isNumericLiteral(value.expression)))
|
|
2343
|
-
// ) {
|
|
2344
|
-
// if (
|
|
2345
|
-
// key === "ref" ||
|
|
2346
|
-
// key.startsWith("use:") ||
|
|
2347
|
-
// key.startsWith("prop:") ||
|
|
2348
|
-
// key.startsWith("on")
|
|
2349
|
-
// )
|
|
2350
|
-
// return memo;
|
|
2351
|
-
|
|
2352
|
-
// memo.push(t.objectProperty(t.stringLiteral(key), value.expression));
|
|
2353
|
-
// } else {
|
|
2354
|
-
// if (key === "$ServerOnly") return memo;
|
|
2355
|
-
// if (t.isJSXExpressionContainer(value)) value = value.expression;
|
|
2356
|
-
// memo.push(
|
|
2357
|
-
// t.objectProperty(t.stringLiteral(key), value ? value : t.booleanLiteral(true))
|
|
2358
|
-
// );
|
|
2359
|
-
// }
|
|
2360
|
-
// return memo;
|
|
2361
|
-
// }, [])
|
|
2362
|
-
// )
|
|
2363
|
-
// );
|
|
2364
2313
|
}
|
|
2365
2314
|
|
|
2366
2315
|
const exprs = [
|
|
@@ -2703,7 +2652,8 @@ function processSpreads(path, attributes, { elem, hasChildren, wrapConditionals
|
|
|
2703
2652
|
const id = convertJSXIdentifier(node.name);
|
|
2704
2653
|
let expr =
|
|
2705
2654
|
wrapConditionals &&
|
|
2706
|
-
(t__namespace.isLogicalExpression(node.value.expression) ||
|
|
2655
|
+
(t__namespace.isLogicalExpression(node.value.expression) ||
|
|
2656
|
+
t__namespace.isConditionalExpression(node.value.expression))
|
|
2707
2657
|
? transformCondition(attribute.get("value").get("expression"), true)
|
|
2708
2658
|
: t__namespace.arrowFunctionExpression([], node.value.expression);
|
|
2709
2659
|
runningObject.push(
|
|
@@ -2975,7 +2925,7 @@ function transformComponent(path) {
|
|
|
2975
2925
|
config.generate !== "ssr" &&
|
|
2976
2926
|
(t__namespace.isLogicalExpression(value.expression) ||
|
|
2977
2927
|
t__namespace.isConditionalExpression(value.expression))
|
|
2978
|
-
? transformCondition
|
|
2928
|
+
? transformCondition(attribute.get("value").get("expression"), true)
|
|
2979
2929
|
: t__namespace.arrowFunctionExpression([], value.expression);
|
|
2980
2930
|
runningObject.push(
|
|
2981
2931
|
t__namespace.objectMethod(
|
|
@@ -3181,7 +3131,7 @@ function transformNode(path, info = {}) {
|
|
|
3181
3131
|
config.wrapConditionals &&
|
|
3182
3132
|
config.generate !== "ssr" &&
|
|
3183
3133
|
(t__namespace.isLogicalExpression(node.expression) || t__namespace.isConditionalExpression(node.expression))
|
|
3184
|
-
? transformCondition
|
|
3134
|
+
? transformCondition(path.get("expression"), info.componentChild)
|
|
3185
3135
|
: !info.componentChild &&
|
|
3186
3136
|
(config.generate !== "ssr" || info.fragmentChild) &&
|
|
3187
3137
|
t__namespace.isCallExpression(node.expression) &&
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-jsx-dom-expressions",
|
|
3
3
|
"description": "A JSX to DOM plugin that wraps expressions for fine grained change detection",
|
|
4
|
-
"version": "0.35.
|
|
4
|
+
"version": "0.35.23",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@babel/core": "^7.20.12"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "3f44ae32aeacdae833f18882b79e34cc1960c1a9"
|
|
35
35
|
}
|