babel-plugin-jsx-dom-expressions 0.35.19 → 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 +9 -36
- 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(
|
|
@@ -2652,7 +2652,8 @@ function processSpreads(path, attributes, { elem, hasChildren, wrapConditionals
|
|
|
2652
2652
|
const id = convertJSXIdentifier(node.name);
|
|
2653
2653
|
let expr =
|
|
2654
2654
|
wrapConditionals &&
|
|
2655
|
-
(t__namespace.isLogicalExpression(node.value.expression) ||
|
|
2655
|
+
(t__namespace.isLogicalExpression(node.value.expression) ||
|
|
2656
|
+
t__namespace.isConditionalExpression(node.value.expression))
|
|
2656
2657
|
? transformCondition(attribute.get("value").get("expression"), true)
|
|
2657
2658
|
: t__namespace.arrowFunctionExpression([], node.value.expression);
|
|
2658
2659
|
runningObject.push(
|
|
@@ -2924,7 +2925,7 @@ function transformComponent(path) {
|
|
|
2924
2925
|
config.generate !== "ssr" &&
|
|
2925
2926
|
(t__namespace.isLogicalExpression(value.expression) ||
|
|
2926
2927
|
t__namespace.isConditionalExpression(value.expression))
|
|
2927
|
-
? transformCondition
|
|
2928
|
+
? transformCondition(attribute.get("value").get("expression"), true)
|
|
2928
2929
|
: t__namespace.arrowFunctionExpression([], value.expression);
|
|
2929
2930
|
runningObject.push(
|
|
2930
2931
|
t__namespace.objectMethod(
|
|
@@ -3033,43 +3034,15 @@ function transformComponentChildren(children, config) {
|
|
|
3033
3034
|
return [transformedChildren, dynamic];
|
|
3034
3035
|
}
|
|
3035
3036
|
|
|
3036
|
-
function insertMarker(path, config, result) {
|
|
3037
|
-
if (config.generate === "ssr") {
|
|
3038
|
-
const open = { template: "<!---->", exprs: [] };
|
|
3039
|
-
result.push(getCreateTemplate(config, path, open)(path, open, true));
|
|
3040
|
-
} else {
|
|
3041
|
-
result.push(t__namespace.stringLiteral("<!>"));
|
|
3042
|
-
}
|
|
3043
|
-
}
|
|
3044
|
-
|
|
3045
3037
|
function transformFragmentChildren(children, results, config) {
|
|
3046
|
-
let prevResult;
|
|
3047
3038
|
const filteredChildren = filterChildren(children),
|
|
3048
3039
|
childNodes = filteredChildren.reduce((memo, path) => {
|
|
3049
3040
|
if (t__namespace.isJSXText(path.node)) {
|
|
3050
3041
|
const v = htmlEntities.decode(trimWhitespace(path.node.extra.raw));
|
|
3051
|
-
if (v.length)
|
|
3052
|
-
if (config.hydratable &&
|
|
3053
|
-
prevResult &&
|
|
3054
|
-
!prevResult.tagName &&
|
|
3055
|
-
!prevResult.component &&
|
|
3056
|
-
prevResult.exprs.length &&
|
|
3057
|
-
!prevResult.spreadElement) insertMarker(path, config, memo);
|
|
3058
|
-
memo.push(t__namespace.stringLiteral(v));
|
|
3059
|
-
prevResult = v;
|
|
3060
|
-
}
|
|
3042
|
+
if (v.length) memo.push(t__namespace.stringLiteral(v));
|
|
3061
3043
|
} else {
|
|
3062
3044
|
const child = transformNode(path, { topLevel: true, fragmentChild: true });
|
|
3063
|
-
const insertMarkers =
|
|
3064
|
-
config.hydratable &&
|
|
3065
|
-
!child.component &&
|
|
3066
|
-
child.exprs.length &&
|
|
3067
|
-
!child.spreadElement &&
|
|
3068
|
-
prevResult &&
|
|
3069
|
-
(typeof prevResult !== "object" || !(prevResult.tagName || prevResult.component));
|
|
3070
|
-
if (insertMarkers) insertMarker(path, config, memo);
|
|
3071
3045
|
memo.push(getCreateTemplate(config, path, child)(path, child, true));
|
|
3072
|
-
prevResult = child;
|
|
3073
3046
|
}
|
|
3074
3047
|
return memo;
|
|
3075
3048
|
}, []);
|
|
@@ -3158,7 +3131,7 @@ function transformNode(path, info = {}) {
|
|
|
3158
3131
|
config.wrapConditionals &&
|
|
3159
3132
|
config.generate !== "ssr" &&
|
|
3160
3133
|
(t__namespace.isLogicalExpression(node.expression) || t__namespace.isConditionalExpression(node.expression))
|
|
3161
|
-
? transformCondition
|
|
3134
|
+
? transformCondition(path.get("expression"), info.componentChild)
|
|
3162
3135
|
: !info.componentChild &&
|
|
3163
3136
|
(config.generate !== "ssr" || info.fragmentChild) &&
|
|
3164
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
|
}
|