babel-plugin-jsx-dom-expressions 0.31.1 → 0.31.11
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 -38
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1150,26 +1150,7 @@ function transformChildren$2(path, results, config) {
|
|
|
1150
1150
|
t__namespace.expressionStatement(
|
|
1151
1151
|
t__namespace.callExpression(
|
|
1152
1152
|
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]]
|
|
1153
|
+
[results.id, child.exprs[0]]
|
|
1173
1154
|
)
|
|
1174
1155
|
)
|
|
1175
1156
|
);
|
|
@@ -1498,12 +1479,14 @@ function transformElement$1(path, info) {
|
|
|
1498
1479
|
};
|
|
1499
1480
|
if (info.topLevel && config.hydratable) {
|
|
1500
1481
|
results.template.push("");
|
|
1501
|
-
results.templateValues.push(
|
|
1482
|
+
results.templateValues.push(
|
|
1483
|
+
t__namespace.callExpression(registerImportMethod(path, "ssrHydrationKey"), [])
|
|
1484
|
+
);
|
|
1502
1485
|
}
|
|
1503
1486
|
transformAttributes$1(path, results);
|
|
1504
1487
|
appendToTemplate(results.template, ">");
|
|
1505
1488
|
if (!voidTag) {
|
|
1506
|
-
transformChildren$1(path, results, {...config, ...info});
|
|
1489
|
+
transformChildren$1(path, results, { ...config, ...info });
|
|
1507
1490
|
appendToTemplate(results.template, `</${tagName}>`);
|
|
1508
1491
|
}
|
|
1509
1492
|
return results;
|
|
@@ -1577,7 +1560,7 @@ function transformToObject(attrName, attributes, selectedAttributes) {
|
|
|
1577
1560
|
const attr = selectedAttributes[i].node;
|
|
1578
1561
|
const computed = !t__namespace.isValidIdentifier(attr.name.name.name);
|
|
1579
1562
|
if (!computed) {
|
|
1580
|
-
attr.name.name.type =
|
|
1563
|
+
attr.name.name.type = "Identifier";
|
|
1581
1564
|
}
|
|
1582
1565
|
properties.push(
|
|
1583
1566
|
t__namespace.objectProperty(
|
|
@@ -1749,7 +1732,10 @@ function transformAttributes$1(path, results) {
|
|
|
1749
1732
|
? p.value
|
|
1750
1733
|
: t__namespace.isTemplateLiteral(p.value) && p.value.expressions.length === 0
|
|
1751
1734
|
? t__namespace.stringLiteral(escapeHTML(p.value.quasis[0].value.raw))
|
|
1752
|
-
: t__namespace.callExpression(registerImportMethod(path, "escape"), [
|
|
1735
|
+
: t__namespace.callExpression(registerImportMethod(path, "escape"), [
|
|
1736
|
+
p.value,
|
|
1737
|
+
t__namespace.booleanLiteral(true)
|
|
1738
|
+
])
|
|
1753
1739
|
)
|
|
1754
1740
|
);
|
|
1755
1741
|
let res = props[0];
|
|
@@ -1758,7 +1744,9 @@ function transformAttributes$1(path, results) {
|
|
|
1758
1744
|
}
|
|
1759
1745
|
value.expression = res;
|
|
1760
1746
|
} else {
|
|
1761
|
-
value.expression = t__namespace.callExpression(registerImportMethod(path, "ssrStyle"), [
|
|
1747
|
+
value.expression = t__namespace.callExpression(registerImportMethod(path, "ssrStyle"), [
|
|
1748
|
+
value.expression
|
|
1749
|
+
]);
|
|
1762
1750
|
}
|
|
1763
1751
|
doEscape = false;
|
|
1764
1752
|
}
|
|
@@ -1775,7 +1763,9 @@ function transformAttributes$1(path, results) {
|
|
|
1775
1763
|
value.expression = values[0];
|
|
1776
1764
|
} else value.expression = t__namespace.templateLiteral(quasis, values);
|
|
1777
1765
|
} else {
|
|
1778
|
-
value.expression = t__namespace.callExpression(registerImportMethod(path, "ssrClassList"), [
|
|
1766
|
+
value.expression = t__namespace.callExpression(registerImportMethod(path, "ssrClassList"), [
|
|
1767
|
+
value.expression
|
|
1768
|
+
]);
|
|
1779
1769
|
}
|
|
1780
1770
|
key = "class";
|
|
1781
1771
|
doEscape = false;
|
|
@@ -1807,7 +1797,10 @@ function transformClasslistObject(path, expr, values, quasis) {
|
|
|
1807
1797
|
let key = prop.key;
|
|
1808
1798
|
if (t__namespace.isIdentifier(prop.key) && !prop.computed) key = t__namespace.stringLiteral(key.name);
|
|
1809
1799
|
else if (prop.computed) {
|
|
1810
|
-
key = t__namespace.callExpression(registerImportMethod(path, "escape"), [
|
|
1800
|
+
key = t__namespace.callExpression(registerImportMethod(path, "escape"), [
|
|
1801
|
+
prop.key,
|
|
1802
|
+
t__namespace.booleanLiteral(true)
|
|
1803
|
+
]);
|
|
1811
1804
|
} else key = t__namespace.stringLiteral(escapeHTML(prop.key.value));
|
|
1812
1805
|
if (t__namespace.isBooleanLiteral(prop.value)) {
|
|
1813
1806
|
if (prop.value.value === true) {
|
|
@@ -1835,7 +1828,7 @@ function transformChildren$1(path, results, { hydratable }) {
|
|
|
1835
1828
|
const doNotEscape = path.doNotEscape;
|
|
1836
1829
|
const filteredChildren = filterChildren(path.get("children"));
|
|
1837
1830
|
filteredChildren.forEach(node => {
|
|
1838
|
-
if (t__namespace.isJSXElement(node.node) &&
|
|
1831
|
+
if (t__namespace.isJSXElement(node.node) && getTagName(node.node) === "head") {
|
|
1839
1832
|
const child = transformNode(node, { doNotEscape, hydratable: false });
|
|
1840
1833
|
registerImportMethod(path, "NoHydration");
|
|
1841
1834
|
results.template.push("");
|
|
@@ -1854,6 +1847,7 @@ function transformChildren$1(path, results, { hydratable }) {
|
|
|
1854
1847
|
return;
|
|
1855
1848
|
}
|
|
1856
1849
|
const child = transformNode(node, { doNotEscape });
|
|
1850
|
+
if (!child) return;
|
|
1857
1851
|
appendToTemplate(results.template, child.template);
|
|
1858
1852
|
results.templateValues.push.apply(results.templateValues, child.templateValues || []);
|
|
1859
1853
|
if (child.exprs.length) {
|
|
@@ -2203,21 +2197,24 @@ function wrapDynamics(path, dynamics) {
|
|
|
2203
2197
|
|
|
2204
2198
|
function convertComponentIdentifier(node) {
|
|
2205
2199
|
if (t__namespace.isJSXIdentifier(node)) {
|
|
2206
|
-
node.type = "Identifier";
|
|
2200
|
+
if (t__namespace.isValidIdentifier(node.name)) node.type = "Identifier";
|
|
2201
|
+
else return t__namespace.stringLiteral(node.name);
|
|
2207
2202
|
} else if (t__namespace.isJSXMemberExpression(node)) {
|
|
2203
|
+
const prop = convertComponentIdentifier(node.property);
|
|
2204
|
+
const computed = t__namespace.isStringLiteral(prop);
|
|
2208
2205
|
return t__namespace.memberExpression(
|
|
2209
2206
|
convertComponentIdentifier(node.object),
|
|
2210
|
-
|
|
2207
|
+
prop,
|
|
2208
|
+
computed
|
|
2211
2209
|
);
|
|
2212
2210
|
}
|
|
2213
2211
|
|
|
2214
2212
|
return node;
|
|
2215
2213
|
}
|
|
2216
2214
|
|
|
2217
|
-
|
|
2218
2215
|
function convertJSXIdentifier(node) {
|
|
2219
2216
|
if (t__namespace.isJSXIdentifier(node)) {
|
|
2220
|
-
if (t__namespace.isValidIdentifier(node.name
|
|
2217
|
+
if (t__namespace.isValidIdentifier(node.name)) {
|
|
2221
2218
|
node.type = "Identifier";
|
|
2222
2219
|
} else {
|
|
2223
2220
|
return t__namespace.stringLiteral(node.name);
|
|
@@ -2225,7 +2222,7 @@ function convertJSXIdentifier(node) {
|
|
|
2225
2222
|
} else if (t__namespace.isJSXMemberExpression(node)) {
|
|
2226
2223
|
return t__namespace.memberExpression(
|
|
2227
2224
|
convertJSXIdentifier(node.object),
|
|
2228
|
-
convertJSXIdentifier(node.property)
|
|
2225
|
+
convertJSXIdentifier(node.property)
|
|
2229
2226
|
);
|
|
2230
2227
|
} else if (t__namespace.isJSXNamespacedName(node)) {
|
|
2231
2228
|
return t__namespace.stringLiteral(`${node.namespace.name}:${node.name.name}`);
|
|
@@ -2431,7 +2428,7 @@ function transformComponentChildren(children, config) {
|
|
|
2431
2428
|
return memo;
|
|
2432
2429
|
}, []);
|
|
2433
2430
|
|
|
2434
|
-
if (
|
|
2431
|
+
if (transformedChildren.length === 1) {
|
|
2435
2432
|
transformedChildren = transformedChildren[0];
|
|
2436
2433
|
if (
|
|
2437
2434
|
!t__namespace.isJSXExpressionContainer(filteredChildren[0]) &&
|
|
@@ -2461,7 +2458,6 @@ function transformFragmentChildren(children, results, config) {
|
|
|
2461
2458
|
? createTemplate$1
|
|
2462
2459
|
: createTemplate$2,
|
|
2463
2460
|
filteredChildren = filterChildren(children),
|
|
2464
|
-
singleChild = filteredChildren.length === 1,
|
|
2465
2461
|
childNodes = filteredChildren.reduce((memo, path) => {
|
|
2466
2462
|
if (t__namespace.isJSXText(path.node)) {
|
|
2467
2463
|
const v = htmlEntities.decode(trimWhitespace(path.node.extra.raw));
|
|
@@ -2472,7 +2468,7 @@ function transformFragmentChildren(children, results, config) {
|
|
|
2472
2468
|
}
|
|
2473
2469
|
return memo;
|
|
2474
2470
|
}, []);
|
|
2475
|
-
results.exprs.push(
|
|
2471
|
+
results.exprs.push(childNodes.length === 1 ? childNodes[0] : t__namespace.arrayExpression(childNodes));
|
|
2476
2472
|
}
|
|
2477
2473
|
|
|
2478
2474
|
function transformJSX(path) {
|
|
@@ -2645,8 +2641,8 @@ var config = {
|
|
|
2645
2641
|
};
|
|
2646
2642
|
|
|
2647
2643
|
var preprocess = (path, { opts }) => {
|
|
2648
|
-
path.hub.file.metadata.config = Object.assign({}, config, opts);
|
|
2649
|
-
const lib =
|
|
2644
|
+
const merged = path.hub.file.metadata.config = Object.assign({}, config, opts);
|
|
2645
|
+
const lib = merged.requireImportSource;
|
|
2650
2646
|
if (lib) {
|
|
2651
2647
|
const comments = path.hub.file.ast.comments;
|
|
2652
2648
|
for(let i = 0; i < comments.length; i++) {
|
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.31.
|
|
4
|
+
"version": "0.31.11",
|
|
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": "fd496194eaf6d4155f2fc27bf4a90bc3ed44b1ac"
|
|
27
27
|
}
|