babel-plugin-jsx-dom-expressions 0.34.0 → 0.34.5
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 +36 -14
- 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);
|
|
@@ -1570,12 +1585,12 @@ function appendToTemplate(template, value) {
|
|
|
1570
1585
|
}
|
|
1571
1586
|
|
|
1572
1587
|
function transformElement$2(path, info) {
|
|
1588
|
+
const config = getConfig(path);
|
|
1573
1589
|
// contains spread attributes
|
|
1574
1590
|
if (path.node.openingElement.attributes.some(a => t__namespace.isJSXSpreadAttribute(a)))
|
|
1575
|
-
return createElement(path, info);
|
|
1591
|
+
return createElement(path, { ...info, ...config });
|
|
1576
1592
|
|
|
1577
1593
|
const tagName = getTagName(path.node),
|
|
1578
|
-
config = getConfig(path),
|
|
1579
1594
|
voidTag = VoidElements.indexOf(tagName) > -1,
|
|
1580
1595
|
results = {
|
|
1581
1596
|
template: [`<${tagName}`],
|
|
@@ -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)) {
|
|
@@ -1926,6 +1944,8 @@ function transformClasslistObject(path, expr, values, quasis) {
|
|
|
1926
1944
|
function transformChildren$1(path, results, { hydratable }) {
|
|
1927
1945
|
const doNotEscape = path.doNotEscape;
|
|
1928
1946
|
const filteredChildren = filterChildren(path.get("children"));
|
|
1947
|
+
const multi = checkLength(filteredChildren),
|
|
1948
|
+
markers = hydratable && multi;
|
|
1929
1949
|
filteredChildren.forEach(node => {
|
|
1930
1950
|
if (t__namespace.isJSXElement(node.node) && getTagName(node.node) === "head") {
|
|
1931
1951
|
const child = transformNode(node, { doNotEscape, hydratable: false });
|
|
@@ -1950,9 +1970,6 @@ function transformChildren$1(path, results, { hydratable }) {
|
|
|
1950
1970
|
appendToTemplate(results.template, child.template);
|
|
1951
1971
|
results.templateValues.push.apply(results.templateValues, child.templateValues || []);
|
|
1952
1972
|
if (child.exprs.length) {
|
|
1953
|
-
const multi = checkLength(filteredChildren),
|
|
1954
|
-
markers = hydratable && multi;
|
|
1955
|
-
|
|
1956
1973
|
if (!doNotEscape) child.exprs[0] = escapeExpression(path, child.exprs[0]);
|
|
1957
1974
|
|
|
1958
1975
|
// boxed by textNodes
|
|
@@ -1969,19 +1986,24 @@ function transformChildren$1(path, results, { hydratable }) {
|
|
|
1969
1986
|
});
|
|
1970
1987
|
}
|
|
1971
1988
|
|
|
1972
|
-
function createElement(path, { topLevel }) {
|
|
1989
|
+
function createElement(path, { topLevel, hydratable }) {
|
|
1973
1990
|
const tagName = getTagName(path.node),
|
|
1974
1991
|
config = getConfig(path),
|
|
1975
1992
|
attributes = normalizeAttributes(path);
|
|
1976
1993
|
|
|
1977
1994
|
const filteredChildren = filterChildren(path.get("children")),
|
|
1995
|
+
multi = checkLength(filteredChildren),
|
|
1996
|
+
markers = hydratable && multi,
|
|
1978
1997
|
childNodes = filteredChildren.reduce((memo, path) => {
|
|
1979
1998
|
if (t__namespace.isJSXText(path.node)) {
|
|
1980
1999
|
const v = htmlEntities.decode(trimWhitespace(path.node.extra.raw));
|
|
1981
2000
|
if (v.length) memo.push(t__namespace.stringLiteral(v));
|
|
1982
2001
|
} else {
|
|
1983
2002
|
const child = transformNode(path);
|
|
2003
|
+
if (markers && child.exprs.length) memo.push(t__namespace.stringLiteral("<!--#-->"));
|
|
2004
|
+
if (hydratable && child.exprs.length) child.exprs[0] = t__namespace.arrowFunctionExpression([], child.exprs[0]);
|
|
1984
2005
|
memo.push(getCreateTemplate(config, path, child)(path, child, true));
|
|
2006
|
+
if (markers && child.exprs.length) memo.push(t__namespace.stringLiteral("<!--/-->"));
|
|
1985
2007
|
}
|
|
1986
2008
|
return memo;
|
|
1987
2009
|
}, []);
|
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.5",
|
|
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": "cf98663093139bb1d6847359732b2f7235d30b61"
|
|
31
31
|
}
|