babel-plugin-jsx-dom-expressions 0.31.5 → 0.32.0
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 +19 -28
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -551,6 +551,7 @@ function transformElement$2(path, info) {
|
|
|
551
551
|
|
|
552
552
|
function setAttr$2(path, elem, name, value, { isSVG, dynamic, prevId, isCE }) {
|
|
553
553
|
// pull out namespace
|
|
554
|
+
const config = getConfig(path);
|
|
554
555
|
let parts, namespace;
|
|
555
556
|
if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
|
|
556
557
|
name = parts[1];
|
|
@@ -595,6 +596,13 @@ function setAttr$2(path, elem, name, value, { isSVG, dynamic, prevId, isCE }) {
|
|
|
595
596
|
);
|
|
596
597
|
}
|
|
597
598
|
|
|
599
|
+
if (config.hydratable && name === "innerHTML") {
|
|
600
|
+
return t__namespace.callExpression(
|
|
601
|
+
registerImportMethod(path, "innerHTML"),
|
|
602
|
+
[elem, value]
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
|
|
598
606
|
if (dynamic && name === "textContent") {
|
|
599
607
|
return t__namespace.assignmentExpression("=", t__namespace.memberExpression(elem, t__namespace.identifier("data")), value);
|
|
600
608
|
}
|
|
@@ -808,7 +816,7 @@ function transformAttributes$2(path, results) {
|
|
|
808
816
|
: node.name.name,
|
|
809
817
|
reservedNameSpace =
|
|
810
818
|
t__namespace.isJSXNamespacedName(node.name) && reservedNameSpaces.has(node.name.namespace.name);
|
|
811
|
-
if (t__namespace.isJSXExpressionContainer(value)) {
|
|
819
|
+
if (t__namespace.isJSXExpressionContainer(value) && !key.startsWith("use:")) {
|
|
812
820
|
const evaluated = attribute.get("value").get("expression").evaluate().value;
|
|
813
821
|
let type;
|
|
814
822
|
if (
|
|
@@ -1150,26 +1158,7 @@ function transformChildren$2(path, results, config) {
|
|
|
1150
1158
|
t__namespace.expressionStatement(
|
|
1151
1159
|
t__namespace.callExpression(
|
|
1152
1160
|
insert,
|
|
1153
|
-
|
|
1154
|
-
? [
|
|
1155
|
-
results.id,
|
|
1156
|
-
child.exprs[0],
|
|
1157
|
-
t__namespace.identifier("undefined"),
|
|
1158
|
-
t__namespace.callExpression(
|
|
1159
|
-
t__namespace.memberExpression(
|
|
1160
|
-
t__namespace.memberExpression(
|
|
1161
|
-
t__namespace.memberExpression(t__namespace.identifier("Array"), t__namespace.identifier("prototype")),
|
|
1162
|
-
t__namespace.identifier("slice")
|
|
1163
|
-
),
|
|
1164
|
-
t__namespace.identifier("call")
|
|
1165
|
-
),
|
|
1166
|
-
[
|
|
1167
|
-
t__namespace.memberExpression(results.id, t__namespace.identifier("childNodes")),
|
|
1168
|
-
t__namespace.numericLiteral(0)
|
|
1169
|
-
]
|
|
1170
|
-
)
|
|
1171
|
-
]
|
|
1172
|
-
: [results.id, child.exprs[0]]
|
|
1161
|
+
[results.id, child.exprs[0]]
|
|
1173
1162
|
)
|
|
1174
1163
|
)
|
|
1175
1164
|
);
|
|
@@ -2216,18 +2205,21 @@ function wrapDynamics(path, dynamics) {
|
|
|
2216
2205
|
|
|
2217
2206
|
function convertComponentIdentifier(node) {
|
|
2218
2207
|
if (t__namespace.isJSXIdentifier(node)) {
|
|
2219
|
-
node.type = "Identifier";
|
|
2208
|
+
if (t__namespace.isValidIdentifier(node.name)) node.type = "Identifier";
|
|
2209
|
+
else return t__namespace.stringLiteral(node.name);
|
|
2220
2210
|
} else if (t__namespace.isJSXMemberExpression(node)) {
|
|
2211
|
+
const prop = convertComponentIdentifier(node.property);
|
|
2212
|
+
const computed = t__namespace.isStringLiteral(prop);
|
|
2221
2213
|
return t__namespace.memberExpression(
|
|
2222
2214
|
convertComponentIdentifier(node.object),
|
|
2223
|
-
|
|
2215
|
+
prop,
|
|
2216
|
+
computed
|
|
2224
2217
|
);
|
|
2225
2218
|
}
|
|
2226
2219
|
|
|
2227
2220
|
return node;
|
|
2228
2221
|
}
|
|
2229
2222
|
|
|
2230
|
-
|
|
2231
2223
|
function convertJSXIdentifier(node) {
|
|
2232
2224
|
if (t__namespace.isJSXIdentifier(node)) {
|
|
2233
2225
|
if (t__namespace.isValidIdentifier(node.name)) {
|
|
@@ -2238,7 +2230,7 @@ function convertJSXIdentifier(node) {
|
|
|
2238
2230
|
} else if (t__namespace.isJSXMemberExpression(node)) {
|
|
2239
2231
|
return t__namespace.memberExpression(
|
|
2240
2232
|
convertJSXIdentifier(node.object),
|
|
2241
|
-
convertJSXIdentifier(node.property)
|
|
2233
|
+
convertJSXIdentifier(node.property)
|
|
2242
2234
|
);
|
|
2243
2235
|
} else if (t__namespace.isJSXNamespacedName(node)) {
|
|
2244
2236
|
return t__namespace.stringLiteral(`${node.namespace.name}:${node.name.name}`);
|
|
@@ -2444,7 +2436,7 @@ function transformComponentChildren(children, config) {
|
|
|
2444
2436
|
return memo;
|
|
2445
2437
|
}, []);
|
|
2446
2438
|
|
|
2447
|
-
if (
|
|
2439
|
+
if (transformedChildren.length === 1) {
|
|
2448
2440
|
transformedChildren = transformedChildren[0];
|
|
2449
2441
|
if (
|
|
2450
2442
|
!t__namespace.isJSXExpressionContainer(filteredChildren[0]) &&
|
|
@@ -2474,7 +2466,6 @@ function transformFragmentChildren(children, results, config) {
|
|
|
2474
2466
|
? createTemplate$1
|
|
2475
2467
|
: createTemplate$2,
|
|
2476
2468
|
filteredChildren = filterChildren(children),
|
|
2477
|
-
singleChild = filteredChildren.length === 1,
|
|
2478
2469
|
childNodes = filteredChildren.reduce((memo, path) => {
|
|
2479
2470
|
if (t__namespace.isJSXText(path.node)) {
|
|
2480
2471
|
const v = htmlEntities.decode(trimWhitespace(path.node.extra.raw));
|
|
@@ -2485,7 +2476,7 @@ function transformFragmentChildren(children, results, config) {
|
|
|
2485
2476
|
}
|
|
2486
2477
|
return memo;
|
|
2487
2478
|
}, []);
|
|
2488
|
-
results.exprs.push(
|
|
2479
|
+
results.exprs.push(childNodes.length === 1 ? childNodes[0] : t__namespace.arrayExpression(childNodes));
|
|
2489
2480
|
}
|
|
2490
2481
|
|
|
2491
2482
|
function transformJSX(path) {
|
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.
|
|
4
|
+
"version": "0.32.0",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"@babel/types": "^7.16.0",
|
|
24
24
|
"html-entities": "2.3.2"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "6c6759c7f721d1e738b3aead7afb5c3cd0be04fc"
|
|
27
27
|
}
|