babel-plugin-jsx-dom-expressions 0.37.20 → 0.37.21

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 +25 -11
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1445,6 +1445,7 @@ function transformAttributes$2(path, results) {
1445
1445
  }
1446
1446
 
1447
1447
  let text = value.value;
1448
+ if (typeof text === "number") text = String(text);
1448
1449
  let needsQuoting = false;
1449
1450
 
1450
1451
  if (key === "style" || key === "class") {
@@ -1926,11 +1927,16 @@ function wrapDynamics$1(path, dynamics) {
1926
1927
  const effectWrapperId = registerImportMethod(path, config.effectWrapper);
1927
1928
 
1928
1929
  if (dynamics.length === 1) {
1930
+ let dynamicStyle;
1929
1931
  const prevValue =
1930
- dynamics[0].key === "classList" || dynamics[0].key === "style"
1932
+ dynamics[0].key === "classList" ||
1933
+ dynamics[0].key === "style" ||
1934
+ (dynamicStyle = dynamics[0].key.startsWith("style:"))
1931
1935
  ? t__namespace.identifier("_$p")
1932
1936
  : undefined;
1933
- if (
1937
+ if (dynamicStyle) {
1938
+ dynamics[0].value = t__namespace.assignmentExpression("=", prevValue, dynamics[0].value);
1939
+ } else if (
1934
1940
  dynamics[0].key.startsWith("class:") &&
1935
1941
  !t__namespace.isBooleanLiteral(dynamics[0].value) &&
1936
1942
  !t__namespace.isUnaryExpression(dynamics[0].value)
@@ -3469,11 +3475,11 @@ function transformThis(path) {
3469
3475
  }
3470
3476
  },
3471
3477
  JSXElement(path) {
3472
- let source = path.get('openingElement').get('name');
3478
+ let source = path.get("openingElement").get("name");
3473
3479
  while (source.isJSXMemberExpression()) {
3474
- source = source.get('object');
3480
+ source = source.get("object");
3475
3481
  }
3476
- if (source.isJSXIdentifier() && source.node.name === 'this') {
3482
+ if (source.isJSXIdentifier() && source.node.name === "this") {
3477
3483
  const current = getTargetFunctionParent(path, parent);
3478
3484
  if (current === parent) {
3479
3485
  thisId || (thisId = path.scope.generateUidIdentifier("self$"));
@@ -3484,15 +3490,23 @@ function transformThis(path) {
3484
3490
  }
3485
3491
  }
3486
3492
  }
3487
- },
3493
+ }
3488
3494
  });
3489
3495
  return node => {
3490
3496
  if (thisId) {
3491
- parent.push({
3492
- id: thisId,
3493
- init: t__namespace.thisExpression(),
3494
- kind: 'const',
3495
- });
3497
+ if (!parent || parent.block.type === "ClassMethod") {
3498
+ const stmt = path.getStatementParent();
3499
+ const decl = t__namespace.variableDeclaration("const", [
3500
+ t__namespace.variableDeclarator(thisId, t__namespace.thisExpression())
3501
+ ]);
3502
+ stmt.insertBefore(decl);
3503
+ } else {
3504
+ parent.push({
3505
+ id: thisId,
3506
+ init: t__namespace.thisExpression(),
3507
+ kind: "const"
3508
+ });
3509
+ }
3496
3510
  }
3497
3511
  return node;
3498
3512
  };
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.37.20",
4
+ "version": "0.37.21",
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": "b23587fced8d2dea9a97bccaa6e8985ce963f137"
34
+ "gitHead": "38ad815b0c610b936ad140ed5c230afe4419d3b7"
35
35
  }