babel-plugin-jsx-dom-expressions 0.36.7 → 0.36.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 +14 -16
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -251,13 +251,7 @@ const reservedNameSpaces = new Set([
251
251
  "attr"
252
252
  ]);
253
253
 
254
- const nonSpreadNameSpaces = new Set([
255
- "class",
256
- "style",
257
- "use",
258
- "prop",
259
- "attr"
260
- ]);
254
+ const nonSpreadNameSpaces = new Set(["class", "style", "use", "prop", "attr"]);
261
255
 
262
256
  function getConfig(path) {
263
257
  return path.hub.file.metadata.config;
@@ -594,7 +588,8 @@ function convertJSXIdentifier(node) {
594
588
  }
595
589
 
596
590
  function canNativeSpread(key, { checkNameSpaces } = {}) {
597
- if (checkNameSpaces && key.includes(":") && nonSpreadNameSpaces.has(key.split(":")[0])) return false;
591
+ if (checkNameSpaces && key.includes(":") && nonSpreadNameSpaces.has(key.split(":")[0]))
592
+ return false;
598
593
  // TODO: figure out how to detect definitely function ref
599
594
  if (key === "ref") return false;
600
595
  return true;
@@ -767,7 +762,7 @@ function transformElement$3(path, info) {
767
762
  results.toBeClosed = new Set(info.toBeClosed || alwaysClose);
768
763
  results.toBeClosed.add(tagName);
769
764
  if (InlineElements.includes(tagName)) BlockElements.forEach(i => results.toBeClosed.add(i));
770
- }
765
+ } else results.toBeClosed = info.toBeClosed;
771
766
  transformChildren$2(path, results, config);
772
767
  if (toBeClosed) results.template += `</${tagName}>`;
773
768
  }
@@ -837,7 +832,10 @@ function setAttr$2(path, elem, name, value, { isSVG, dynamic, prevId, isCE, tagN
837
832
  t__namespace.memberExpression(elem, t__namespace.identifier("classList")),
838
833
  t__namespace.identifier("toggle")
839
834
  ),
840
- [t__namespace.stringLiteral(name), value]
835
+ [
836
+ t__namespace.stringLiteral(name),
837
+ dynamic ? value : t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", value))
838
+ ]
841
839
  );
842
840
  }
843
841
 
@@ -1393,7 +1391,7 @@ function findLastElement(children, hydratable) {
1393
1391
  if (
1394
1392
  hydratable ||
1395
1393
  t__namespace.isJSXText(node) ||
1396
- getStaticExpression(children[i]) ||
1394
+ getStaticExpression(children[i]) !== false ||
1397
1395
  (t__namespace.isJSXElement(node) && (tagName = getTagName(node)) && !isComponent(tagName))
1398
1396
  ) {
1399
1397
  lastElement = i;
@@ -1572,7 +1570,7 @@ function detectExpressions(children, index, config) {
1572
1570
  if (
1573
1571
  t__namespace.isJSXExpressionContainer(node) &&
1574
1572
  !t__namespace.isJSXEmptyExpression(node.expression) &&
1575
- !getStaticExpression(children[index - 1])
1573
+ getStaticExpression(children[index - 1]) === false
1576
1574
  )
1577
1575
  return true;
1578
1576
  let tagName;
@@ -1581,7 +1579,7 @@ function detectExpressions(children, index, config) {
1581
1579
  for (let i = index; i < children.length; i++) {
1582
1580
  const child = children[i].node;
1583
1581
  if (t__namespace.isJSXExpressionContainer(child)) {
1584
- if (!t__namespace.isJSXEmptyExpression(child.expression) && !getStaticExpression(children[i]))
1582
+ if (!t__namespace.isJSXEmptyExpression(child.expression) && getStaticExpression(children[i]) === false)
1585
1583
  return true;
1586
1584
  } else if (t__namespace.isJSXElement(child)) {
1587
1585
  const tagName = getTagName(child);
@@ -3316,7 +3314,7 @@ function transformNode(path, info = {}) {
3316
3314
  // <><div /><Component /></>
3317
3315
  transformFragmentChildren(path.get("children"), results, config);
3318
3316
  return results;
3319
- } else if (t__namespace.isJSXText(node) || (staticValue = getStaticExpression(path))) {
3317
+ } else if (t__namespace.isJSXText(node) || (staticValue = getStaticExpression(path)) !== false) {
3320
3318
  const text =
3321
3319
  staticValue !== undefined
3322
3320
  ? info.doNotEscape
@@ -3412,8 +3410,8 @@ function transformElement(config, path, info = {}) {
3412
3410
  // <div ...></div>
3413
3411
  // const element = getTransformElemet(config, path, tagName);
3414
3412
 
3415
- const tagRenderer = (config.renderers ?? []).find(
3416
- renderer => renderer.elements.includes(tagName)
3413
+ const tagRenderer = (config.renderers ?? []).find(renderer =>
3414
+ renderer.elements.includes(tagName)
3417
3415
  );
3418
3416
 
3419
3417
  if (tagRenderer?.name === "dom" || getConfig(path).generate === "dom") {
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.7",
4
+ "version": "0.36.9",
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": "cde236af9c2dfc9ab4642c08decf06fc90172e5f"
34
+ "gitHead": "eccf8327e8f09029d94273d4c9a70360651313e8"
35
35
  }