babel-plugin-jsx-dom-expressions 0.35.17 → 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 +34 -56
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var SyntaxJSX = require('@babel/plugin-syntax-jsx');
|
|
4
4
|
var t = require('@babel/types');
|
|
5
|
-
var htmlEntities = require('html-entities');
|
|
6
5
|
var helperModuleImports = require('@babel/helper-module-imports');
|
|
6
|
+
var htmlEntities = require('html-entities');
|
|
7
7
|
|
|
8
8
|
function _interopNamespaceDefault(e) {
|
|
9
9
|
var n = Object.create(null);
|
|
@@ -1181,7 +1181,7 @@ function transformAttributes$2(path, results) {
|
|
|
1181
1181
|
} else {
|
|
1182
1182
|
!isSVG && (key = key.toLowerCase());
|
|
1183
1183
|
results.template += ` ${key}`;
|
|
1184
|
-
results.template += value ? `="${escapeBackticks(escapeHTML(
|
|
1184
|
+
results.template += value ? `="${escapeBackticks(escapeHTML(value.value, true))}"` : "";
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
1187
1187
|
});
|
|
@@ -2126,7 +2126,7 @@ function transformAttributes$1(path, results, info) {
|
|
|
2126
2126
|
if (t__namespace.isJSXExpressionContainer(value)) value = value.expression;
|
|
2127
2127
|
key = toAttribute(key, isSVG);
|
|
2128
2128
|
appendToTemplate(results.template, ` ${key}`);
|
|
2129
|
-
appendToTemplate(results.template, value ? `="${escapeHTML(
|
|
2129
|
+
appendToTemplate(results.template, value ? `="${escapeHTML(value.value, true)}"` : "");
|
|
2130
2130
|
}
|
|
2131
2131
|
});
|
|
2132
2132
|
if (!hasChildren && children) {
|
|
@@ -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 = [
|
|
@@ -2890,7 +2839,8 @@ function transformComponent(path) {
|
|
|
2890
2839
|
: node.argument
|
|
2891
2840
|
);
|
|
2892
2841
|
} else {
|
|
2893
|
-
|
|
2842
|
+
// handle weird babel bug around HTML entities
|
|
2843
|
+
const value = (t__namespace.isStringLiteral(node.value) ? t__namespace.stringLiteral(node.value.value): node.value) || t__namespace.booleanLiteral(true),
|
|
2894
2844
|
id = convertJSXIdentifier(node.name),
|
|
2895
2845
|
key = id.name;
|
|
2896
2846
|
if (hasChildren && key === "children") return;
|
|
@@ -3083,15 +3033,43 @@ function transformComponentChildren(children, config) {
|
|
|
3083
3033
|
return [transformedChildren, dynamic];
|
|
3084
3034
|
}
|
|
3085
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
|
+
|
|
3086
3045
|
function transformFragmentChildren(children, results, config) {
|
|
3046
|
+
let prevResult;
|
|
3087
3047
|
const filteredChildren = filterChildren(children),
|
|
3088
3048
|
childNodes = filteredChildren.reduce((memo, path) => {
|
|
3089
3049
|
if (t__namespace.isJSXText(path.node)) {
|
|
3090
3050
|
const v = htmlEntities.decode(trimWhitespace(path.node.extra.raw));
|
|
3091
|
-
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
|
+
}
|
|
3092
3061
|
} else {
|
|
3093
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);
|
|
3094
3071
|
memo.push(getCreateTemplate(config, path, child)(path, child, true));
|
|
3072
|
+
prevResult = child;
|
|
3095
3073
|
}
|
|
3096
3074
|
return memo;
|
|
3097
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
|
}
|