babel-plugin-jsx-dom-expressions 0.37.20 → 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.
- package/index.js +34 -12
- 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" ||
|
|
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)
|
|
@@ -3298,7 +3304,8 @@ function transformComponent(path) {
|
|
|
3298
3304
|
);
|
|
3299
3305
|
} else if (
|
|
3300
3306
|
t__namespace.isCallExpression(value.expression) &&
|
|
3301
|
-
t__namespace.isArrowFunctionExpression(value.expression.callee)
|
|
3307
|
+
t__namespace.isArrowFunctionExpression(value.expression.callee) &&
|
|
3308
|
+
value.expression.callee.params.length === 0
|
|
3302
3309
|
) {
|
|
3303
3310
|
const callee = value.expression.callee;
|
|
3304
3311
|
const body = t__namespace.isBlockStatement(callee.body)
|
|
@@ -3469,11 +3476,11 @@ function transformThis(path) {
|
|
|
3469
3476
|
}
|
|
3470
3477
|
},
|
|
3471
3478
|
JSXElement(path) {
|
|
3472
|
-
let source = path.get(
|
|
3479
|
+
let source = path.get("openingElement").get("name");
|
|
3473
3480
|
while (source.isJSXMemberExpression()) {
|
|
3474
|
-
source = source.get(
|
|
3481
|
+
source = source.get("object");
|
|
3475
3482
|
}
|
|
3476
|
-
if (source.isJSXIdentifier() && source.node.name ===
|
|
3483
|
+
if (source.isJSXIdentifier() && source.node.name === "this") {
|
|
3477
3484
|
const current = getTargetFunctionParent(path, parent);
|
|
3478
3485
|
if (current === parent) {
|
|
3479
3486
|
thisId || (thisId = path.scope.generateUidIdentifier("self$"));
|
|
@@ -3484,15 +3491,30 @@ function transformThis(path) {
|
|
|
3484
3491
|
}
|
|
3485
3492
|
}
|
|
3486
3493
|
}
|
|
3487
|
-
}
|
|
3494
|
+
}
|
|
3488
3495
|
});
|
|
3489
3496
|
return node => {
|
|
3490
3497
|
if (thisId) {
|
|
3491
|
-
parent.
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3498
|
+
if (!parent || parent.block.type === "ClassMethod") {
|
|
3499
|
+
const decl = t__namespace.variableDeclaration("const", [
|
|
3500
|
+
t__namespace.variableDeclarator(thisId, t__namespace.thisExpression())
|
|
3501
|
+
]);
|
|
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
|
+
}
|
|
3511
|
+
} else {
|
|
3512
|
+
parent.push({
|
|
3513
|
+
id: thisId,
|
|
3514
|
+
init: t__namespace.thisExpression(),
|
|
3515
|
+
kind: "const"
|
|
3516
|
+
});
|
|
3517
|
+
}
|
|
3496
3518
|
}
|
|
3497
3519
|
return node;
|
|
3498
3520
|
};
|
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.
|
|
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": "
|
|
34
|
+
"gitHead": "8fa34b71f185b76a910fca56980bb5297638f768"
|
|
35
35
|
}
|