babel-plugin-jsx-dom-expressions 0.31.0 → 0.31.9

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.
Files changed (2) hide show
  1. package/index.js +26 -32
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -466,7 +466,7 @@ function transformCondition(path, inline, deep) {
466
466
  }
467
467
 
468
468
  function escapeBackticks(value) {
469
- return value.replaceAll("`", "\\`");
469
+ return value.replace(/`/g, "\\`");
470
470
  }
471
471
 
472
472
  function escapeHTML(s, attr) {
@@ -1150,26 +1150,7 @@ function transformChildren$2(path, results, config) {
1150
1150
  t__namespace.expressionStatement(
1151
1151
  t__namespace.callExpression(
1152
1152
  insert,
1153
- config.hydratable
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(t__namespace.callExpression(registerImportMethod(path, "ssrHydrationKey"), []));
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 = 'Identifier';
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"), [p.value, t__namespace.booleanLiteral(true)])
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"), [value.expression]);
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"), [value.expression]);
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"), [prop.key, t__namespace.booleanLiteral(true)]);
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) && (getTagName(node.node) === "head")) {
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) {
@@ -2217,7 +2211,7 @@ function convertComponentIdentifier(node) {
2217
2211
 
2218
2212
  function convertJSXIdentifier(node) {
2219
2213
  if (t__namespace.isJSXIdentifier(node)) {
2220
- if (t__namespace.isValidIdentifier(node.name, false)) {
2214
+ if (t__namespace.isValidIdentifier(node.name)) {
2221
2215
  node.type = "Identifier";
2222
2216
  } else {
2223
2217
  return t__namespace.stringLiteral(node.name);
@@ -2645,8 +2639,8 @@ var config = {
2645
2639
  };
2646
2640
 
2647
2641
  var preprocess = (path, { opts }) => {
2648
- path.hub.file.metadata.config = Object.assign({}, config, opts);
2649
- const lib = config.requireImportSource;
2642
+ const merged = path.hub.file.metadata.config = Object.assign({}, config, opts);
2643
+ const lib = merged.requireImportSource;
2650
2644
  if (lib) {
2651
2645
  const comments = path.hub.file.ast.comments;
2652
2646
  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.0",
4
+ "version": "0.31.9",
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": "f6597dac2273ec022b8859ce868f6138b0c2a180"
26
+ "gitHead": "d6acdfaec8fd29efa9954a56f1f6d068b9b8e528"
27
27
  }