babel-plugin-jsx-dom-expressions 0.35.18 → 0.35.19
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 +29 -52
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -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 = [
|
|
@@ -3084,15 +3033,43 @@ function transformComponentChildren(children, config) {
|
|
|
3084
3033
|
return [transformedChildren, dynamic];
|
|
3085
3034
|
}
|
|
3086
3035
|
|
|
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
|
+
|
|
3087
3045
|
function transformFragmentChildren(children, results, config) {
|
|
3046
|
+
let prevResult;
|
|
3088
3047
|
const filteredChildren = filterChildren(children),
|
|
3089
3048
|
childNodes = filteredChildren.reduce((memo, path) => {
|
|
3090
3049
|
if (t__namespace.isJSXText(path.node)) {
|
|
3091
3050
|
const v = htmlEntities.decode(trimWhitespace(path.node.extra.raw));
|
|
3092
|
-
if (v.length)
|
|
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
|
+
}
|
|
3093
3061
|
} else {
|
|
3094
3062
|
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);
|
|
3095
3071
|
memo.push(getCreateTemplate(config, path, child)(path, child, true));
|
|
3072
|
+
prevResult = child;
|
|
3096
3073
|
}
|
|
3097
3074
|
return memo;
|
|
3098
3075
|
}, []);
|
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.19",
|
|
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": "cd607bb1bc035812f1b8bfae3c75d60c5c52143c"
|
|
35
35
|
}
|