babel-plugin-jsx-dom-expressions 0.36.3 → 0.36.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.
Files changed (2) hide show
  1. package/index.js +64 -7
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -600,7 +600,27 @@ function canNativeSpread(key, { checkNameSpaces } = {}) {
600
600
  return true;
601
601
  }
602
602
 
603
- const alwaysClose = ["a", "table", "textarea", "select", "b", "strong", "small", "i", "em"];
603
+ const alwaysClose = [
604
+ "title",
605
+ "style",
606
+ "a",
607
+ "strong",
608
+ "small",
609
+ "b",
610
+ "u",
611
+ "i",
612
+ "em",
613
+ "s",
614
+ "code",
615
+ "object",
616
+ "table",
617
+ "button",
618
+ "textarea",
619
+ "select",
620
+ "iframe",
621
+ "script",
622
+ "template"
623
+ ];
604
624
 
605
625
  const BlockElements = [
606
626
  "address",
@@ -609,6 +629,7 @@ const BlockElements = [
609
629
  "blockquote",
610
630
  "canvas",
611
631
  "dd",
632
+ "details",
612
633
  "div",
613
634
  "dl",
614
635
  "dt",
@@ -718,14 +739,43 @@ function setAttr$2(path, elem, name, value, { isSVG, dynamic, prevId, isCE, tagN
718
739
  namespace = parts[0];
719
740
  }
720
741
 
742
+ // TODO: consider moving to a helper
721
743
  if (namespace === "style") {
722
- return t__namespace.callExpression(
744
+ if (t__namespace.isStringLiteral(value)) {
745
+ return t__namespace.callExpression(
746
+ t__namespace.memberExpression(
747
+ t__namespace.memberExpression(elem, t__namespace.identifier("style")),
748
+ t__namespace.identifier("setProperty")
749
+ ),
750
+ [t__namespace.stringLiteral(name), value]
751
+ );
752
+ }
753
+ if (t__namespace.isNullLiteral(value) || t__namespace.isIdentifier(value, { name: "undefined" })) {
754
+ return t__namespace.callExpression(
755
+ t__namespace.memberExpression(
756
+ t__namespace.memberExpression(elem, t__namespace.identifier("style")),
757
+ t__namespace.identifier("removeProperty")
758
+ ),
759
+ [t__namespace.stringLiteral(name)]
760
+ );
761
+ }
762
+ return t__namespace.conditionalExpression(t__namespace.binaryExpression(
763
+ "!=",
764
+ value,
765
+ t__namespace.nullLiteral()
766
+ ), t__namespace.callExpression(
723
767
  t__namespace.memberExpression(
724
768
  t__namespace.memberExpression(elem, t__namespace.identifier("style")),
725
769
  t__namespace.identifier("setProperty")
726
770
  ),
727
- [t__namespace.stringLiteral(name), value]
728
- );
771
+ [t__namespace.stringLiteral(name), prevId ? prevId : value]
772
+ ), t__namespace.callExpression(
773
+ t__namespace.memberExpression(
774
+ t__namespace.memberExpression(elem, t__namespace.identifier("style")),
775
+ t__namespace.identifier("removeProperty")
776
+ ),
777
+ [t__namespace.stringLiteral(name)]
778
+ ));
729
779
  }
730
780
 
731
781
  if (namespace === "class") {
@@ -1283,10 +1333,16 @@ function transformAttributes$2(path, results) {
1283
1333
  }
1284
1334
 
1285
1335
  function findLastElement(children, hydratable) {
1286
- let lastElement = -1, tagName;
1336
+ let lastElement = -1,
1337
+ tagName;
1287
1338
  for (let i = children.length - 1; i >= 0; i--) {
1288
1339
  const node = children[i].node;
1289
- if (hydratable || t__namespace.isJSXText(node) || getStaticExpression(children[i]) || (t__namespace.isJSXElement(node) && (tagName = getTagName(node)) && !isComponent(tagName))) {
1340
+ if (
1341
+ hydratable ||
1342
+ t__namespace.isJSXText(node) ||
1343
+ getStaticExpression(children[i]) ||
1344
+ (t__namespace.isJSXElement(node) && (tagName = getTagName(node)) && !isComponent(tagName))
1345
+ ) {
1290
1346
  lastElement = i;
1291
1347
  break;
1292
1348
  }
@@ -1761,6 +1817,7 @@ function wrapDynamics$1(path, dynamics) {
1761
1817
  )
1762
1818
  );
1763
1819
  } else {
1820
+ const prev = key.startsWith("style:") ? identifier : undefined;
1764
1821
  statements.push(
1765
1822
  t__namespace.expressionStatement(
1766
1823
  t__namespace.logicalExpression(
@@ -1771,7 +1828,7 @@ function wrapDynamics$1(path, dynamics) {
1771
1828
  elem,
1772
1829
  key,
1773
1830
  t__namespace.assignmentExpression("=", t__namespace.memberExpression(prevId, identifier), identifier),
1774
- { isSVG, isCE, tagName, dynamic: true }
1831
+ { isSVG, isCE, tagName, dynamic: true, prevId: prev }
1775
1832
  )
1776
1833
  )
1777
1834
  )
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.36.3",
4
+ "version": "0.36.5",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -31,5 +31,5 @@
31
31
  "devDependencies": {
32
32
  "@babel/core": "^7.20.12"
33
33
  },
34
- "gitHead": "a25b3864d80f6fb4378fa82634a12675a72b6991"
34
+ "gitHead": "d0146a831acf798245be5f3e459a83a10cb2a3dc"
35
35
  }