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

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 +11 -3
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -3304,7 +3304,8 @@ function transformComponent(path) {
3304
3304
  );
3305
3305
  } else if (
3306
3306
  t__namespace.isCallExpression(value.expression) &&
3307
- t__namespace.isArrowFunctionExpression(value.expression.callee)
3307
+ t__namespace.isArrowFunctionExpression(value.expression.callee) &&
3308
+ value.expression.callee.params.length === 0
3308
3309
  ) {
3309
3310
  const callee = value.expression.callee;
3310
3311
  const body = t__namespace.isBlockStatement(callee.body)
@@ -3495,11 +3496,18 @@ function transformThis(path) {
3495
3496
  return node => {
3496
3497
  if (thisId) {
3497
3498
  if (!parent || parent.block.type === "ClassMethod") {
3498
- const stmt = path.getStatementParent();
3499
3499
  const decl = t__namespace.variableDeclaration("const", [
3500
3500
  t__namespace.variableDeclarator(thisId, t__namespace.thisExpression())
3501
3501
  ]);
3502
- stmt.insertBefore(decl);
3502
+ if (parent) {
3503
+ const stmt = path.getStatementParent();
3504
+ stmt.insertBefore(decl);
3505
+ } else {
3506
+ return t__namespace.callExpression(
3507
+ t__namespace.arrowFunctionExpression([], t__namespace.blockStatement([decl, t__namespace.returnStatement(node)])),
3508
+ []
3509
+ );
3510
+ }
3503
3511
  } else {
3504
3512
  parent.push({
3505
3513
  id: thisId,
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.21",
4
+ "version": "0.37.22",
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": "38ad815b0c610b936ad140ed5c230afe4419d3b7"
34
+ "gitHead": "8fa34b71f185b76a910fca56980bb5297638f768"
35
35
  }