babel-plugin-jsx-dom-expressions 0.34.1 → 0.34.7
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 +35 -10
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1416,9 +1416,18 @@ function registerTemplate(path, results) {
|
|
|
1416
1416
|
templateId ? [templateId] : []
|
|
1417
1417
|
)
|
|
1418
1418
|
: results.hasCustomElement
|
|
1419
|
-
? t__namespace.callExpression(
|
|
1420
|
-
|
|
1421
|
-
|
|
1419
|
+
? t__namespace.callExpression(
|
|
1420
|
+
registerImportMethod(path, "untrack", getRendererConfig(path, "dom").moduleName),
|
|
1421
|
+
[
|
|
1422
|
+
t__namespace.arrowFunctionExpression(
|
|
1423
|
+
[],
|
|
1424
|
+
t__namespace.callExpression(
|
|
1425
|
+
t__namespace.memberExpression(t__namespace.identifier("document"), t__namespace.identifier("importNode")),
|
|
1426
|
+
[templateId, t__namespace.booleanLiteral(true)]
|
|
1427
|
+
)
|
|
1428
|
+
)
|
|
1429
|
+
]
|
|
1430
|
+
)
|
|
1422
1431
|
: t__namespace.callExpression(t__namespace.memberExpression(templateId, t__namespace.identifier("cloneNode")), [
|
|
1423
1432
|
t__namespace.booleanLiteral(true)
|
|
1424
1433
|
])
|
|
@@ -1439,9 +1448,14 @@ function wrapDynamics$1(path, dynamics) {
|
|
|
1439
1448
|
dynamics[0].key === "classList" || dynamics[0].key === "style"
|
|
1440
1449
|
? t__namespace.identifier("_$p")
|
|
1441
1450
|
: undefined;
|
|
1442
|
-
if (
|
|
1451
|
+
if (
|
|
1452
|
+
dynamics[0].key.startsWith("class:") &&
|
|
1453
|
+
!t__namespace.isBooleanLiteral(dynamics[0].value) &&
|
|
1454
|
+
!t__namespace.isUnaryExpression(dynamics[0].value)
|
|
1455
|
+
) {
|
|
1443
1456
|
dynamics[0].value = t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", dynamics[0].value));
|
|
1444
1457
|
}
|
|
1458
|
+
|
|
1445
1459
|
return t__namespace.expressionStatement(
|
|
1446
1460
|
t__namespace.callExpression(effectWrapperId, [
|
|
1447
1461
|
t__namespace.arrowFunctionExpression(
|
|
@@ -1464,7 +1478,8 @@ function wrapDynamics$1(path, dynamics) {
|
|
|
1464
1478
|
const identifier = path.scope.generateUidIdentifier("v$");
|
|
1465
1479
|
if (key.startsWith("class:") && !t__namespace.isBooleanLiteral(value) && !t__namespace.isUnaryExpression(value)) {
|
|
1466
1480
|
value = t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", value));
|
|
1467
|
-
}
|
|
1481
|
+
}
|
|
1482
|
+
identifiers.push(identifier);
|
|
1468
1483
|
decls.push(t__namespace.variableDeclarator(identifier, value));
|
|
1469
1484
|
if (key === "classList" || key === "style") {
|
|
1470
1485
|
const prev = t__namespace.memberExpression(prevId, identifier);
|
|
@@ -1593,7 +1608,7 @@ function transformElement$2(path, info) {
|
|
|
1593
1608
|
t__namespace.callExpression(registerImportMethod(path, "ssrHydrationKey"), [])
|
|
1594
1609
|
);
|
|
1595
1610
|
}
|
|
1596
|
-
transformAttributes$1(path, results);
|
|
1611
|
+
transformAttributes$1(path, results, { ...config, ...info });
|
|
1597
1612
|
appendToTemplate(results.template, ">");
|
|
1598
1613
|
if (!voidTag) {
|
|
1599
1614
|
transformChildren$1(path, results, { ...config, ...info });
|
|
@@ -1761,7 +1776,7 @@ function normalizeAttributes(path) {
|
|
|
1761
1776
|
return attributes;
|
|
1762
1777
|
}
|
|
1763
1778
|
|
|
1764
|
-
function transformAttributes$1(path, results) {
|
|
1779
|
+
function transformAttributes$1(path, results, info) {
|
|
1765
1780
|
const tagName = getTagName(path.node),
|
|
1766
1781
|
isSVG = SVGElements.has(tagName),
|
|
1767
1782
|
hasChildren = path.node.children.length > 0,
|
|
@@ -1798,8 +1813,11 @@ function transformAttributes$1(path, results) {
|
|
|
1798
1813
|
)
|
|
1799
1814
|
return;
|
|
1800
1815
|
else if (ChildProperties.has(key)) {
|
|
1801
|
-
|
|
1816
|
+
if (info.hydratable && key === "textContent" && value && value.expression) {
|
|
1817
|
+
value.expression = t__namespace.logicalExpression("||", value.expression, t__namespace.stringLiteral(" "));
|
|
1818
|
+
}
|
|
1802
1819
|
if (key === "innerHTML") path.doNotEscape = true;
|
|
1820
|
+
children = value;
|
|
1803
1821
|
} else {
|
|
1804
1822
|
let doEscape = true;
|
|
1805
1823
|
if (BooleanAttributes.has(key)) {
|
|
@@ -1972,6 +1990,9 @@ function createElement(path, { topLevel, hydratable }) {
|
|
|
1972
1990
|
const tagName = getTagName(path.node),
|
|
1973
1991
|
config = getConfig(path),
|
|
1974
1992
|
attributes = normalizeAttributes(path);
|
|
1993
|
+
isDynamic(path, {
|
|
1994
|
+
checkMember: true
|
|
1995
|
+
});
|
|
1975
1996
|
|
|
1976
1997
|
const filteredChildren = filterChildren(path.get("children")),
|
|
1977
1998
|
multi = checkLength(filteredChildren),
|
|
@@ -1983,7 +2004,6 @@ function createElement(path, { topLevel, hydratable }) {
|
|
|
1983
2004
|
} else {
|
|
1984
2005
|
const child = transformNode(path);
|
|
1985
2006
|
if (markers && child.exprs.length) memo.push(t__namespace.stringLiteral("<!--#-->"));
|
|
1986
|
-
if (hydratable && child.exprs.length) child.exprs[0] = t__namespace.arrowFunctionExpression([], child.exprs[0]);
|
|
1987
2007
|
memo.push(getCreateTemplate(config, path, child)(path, child, true));
|
|
1988
2008
|
if (markers && child.exprs.length) memo.push(t__namespace.stringLiteral("<!--/-->"));
|
|
1989
2009
|
}
|
|
@@ -2046,7 +2066,12 @@ function createElement(path, { topLevel, hydratable }) {
|
|
|
2046
2066
|
t__namespace.stringLiteral(tagName),
|
|
2047
2067
|
transformed,
|
|
2048
2068
|
childNodes.length
|
|
2049
|
-
?
|
|
2069
|
+
? hydratable
|
|
2070
|
+
? t__namespace.arrowFunctionExpression(
|
|
2071
|
+
[],
|
|
2072
|
+
childNodes.length === 1 ? childNodes[0] : t__namespace.arrayExpression(childNodes)
|
|
2073
|
+
)
|
|
2074
|
+
: childNodes.length === 1
|
|
2050
2075
|
? childNodes[0]
|
|
2051
2076
|
: t__namespace.arrayExpression(childNodes)
|
|
2052
2077
|
: t__namespace.identifier("undefined"),
|
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.34.
|
|
4
|
+
"version": "0.34.7",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@babel/core": "^7.0.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "df8d6142fe3d73ef2895f4bf54731eb514fb72ab"
|
|
31
31
|
}
|