babel-plugin-jsx-dom-expressions 0.36.9 → 0.36.18
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/README.md +14 -1
- package/index.js +40 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -130,7 +130,7 @@ Array of Component exports from module, that aren't included by default with the
|
|
|
130
130
|
|
|
131
131
|
- Type: `string`
|
|
132
132
|
- Default: `effect`
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
This plugin leverages a heuristic for reactive wrapping and lazy evaluation of JSX expressions. This option indicates the reactive wrapper function name (`effect`), defaults to `effect`.
|
|
135
135
|
|
|
136
136
|
### staticMarker
|
|
@@ -147,6 +147,19 @@ Comment decorator string indicates the static expression, used to tell the compi
|
|
|
147
147
|
|
|
148
148
|
Memos let you efficiently use a derived value in many reactive computations. This option indicates the memo function name, defaults to `memo`.
|
|
149
149
|
|
|
150
|
+
### validate
|
|
151
|
+
|
|
152
|
+
- Type: `boolean`
|
|
153
|
+
- Default: `true`
|
|
154
|
+
|
|
155
|
+
Checks for properly formed HTML by checking for elements that would not be allowed in certain parent elements. This validation isn't complete but includes places where browser would "correct" it and break the DOM walks.
|
|
156
|
+
|
|
157
|
+
### omitNestedClosingTags
|
|
158
|
+
|
|
159
|
+
- Type: `boolean`
|
|
160
|
+
- Default: `true`
|
|
161
|
+
|
|
162
|
+
Removes unnecessary closing tags from the template output. This may not work in all browser-like environments the same. The solution has been tested again Chrome/Edge/Firefox/Safari.
|
|
150
163
|
|
|
151
164
|
## Special Binding
|
|
152
165
|
|
package/index.js
CHANGED
|
@@ -707,7 +707,8 @@ const alwaysClose = [
|
|
|
707
707
|
"select",
|
|
708
708
|
"iframe",
|
|
709
709
|
"script",
|
|
710
|
-
"template"
|
|
710
|
+
"template",
|
|
711
|
+
"fieldset"
|
|
711
712
|
];
|
|
712
713
|
|
|
713
714
|
function transformElement$3(path, info) {
|
|
@@ -757,7 +758,9 @@ function transformElement$3(path, info) {
|
|
|
757
758
|
results.template += ">";
|
|
758
759
|
if (!voidTag) {
|
|
759
760
|
// always close tags can still be skipped if they have no closing parents and are the last element
|
|
760
|
-
const toBeClosed =
|
|
761
|
+
const toBeClosed =
|
|
762
|
+
!info.lastElement ||
|
|
763
|
+
(info.toBeClosed && (!config.omitNestedClosingTags || info.toBeClosed.has(tagName)));
|
|
761
764
|
if (toBeClosed) {
|
|
762
765
|
results.toBeClosed = new Set(info.toBeClosed || alwaysClose);
|
|
763
766
|
results.toBeClosed.add(tagName);
|
|
@@ -3135,22 +3138,44 @@ function transformComponent(path) {
|
|
|
3135
3138
|
checkTags: true
|
|
3136
3139
|
})
|
|
3137
3140
|
) {
|
|
3138
|
-
|
|
3141
|
+
if (
|
|
3139
3142
|
config.wrapConditionals &&
|
|
3140
3143
|
config.generate !== "ssr" &&
|
|
3141
3144
|
(t__namespace.isLogicalExpression(value.expression) ||
|
|
3142
3145
|
t__namespace.isConditionalExpression(value.expression))
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3146
|
+
) {
|
|
3147
|
+
const expr = transformCondition(attribute.get("value").get("expression"), true);
|
|
3148
|
+
|
|
3149
|
+
runningObject.push(
|
|
3150
|
+
t__namespace.objectMethod(
|
|
3151
|
+
"get",
|
|
3152
|
+
id,
|
|
3153
|
+
[],
|
|
3154
|
+
t__namespace.blockStatement([t__namespace.returnStatement(expr.body)]),
|
|
3155
|
+
!t__namespace.isValidIdentifier(key)
|
|
3156
|
+
)
|
|
3157
|
+
);
|
|
3158
|
+
} else if (
|
|
3159
|
+
t__namespace.isCallExpression(value.expression) &&
|
|
3160
|
+
t__namespace.isArrowFunctionExpression(value.expression.callee)
|
|
3161
|
+
) {
|
|
3162
|
+
const callee = value.expression.callee;
|
|
3163
|
+
const body = t__namespace.isBlockStatement(callee.body)
|
|
3164
|
+
? callee.body
|
|
3165
|
+
: t__namespace.blockStatement([t__namespace.returnStatement(callee.body)]);
|
|
3166
|
+
|
|
3167
|
+
runningObject.push(t__namespace.objectMethod("get", id, [], body, !t__namespace.isValidIdentifier(key)));
|
|
3168
|
+
} else {
|
|
3169
|
+
runningObject.push(
|
|
3170
|
+
t__namespace.objectMethod(
|
|
3171
|
+
"get",
|
|
3172
|
+
id,
|
|
3173
|
+
[],
|
|
3174
|
+
t__namespace.blockStatement([t__namespace.returnStatement(value.expression)]),
|
|
3175
|
+
!t__namespace.isValidIdentifier(key)
|
|
3176
|
+
)
|
|
3177
|
+
);
|
|
3178
|
+
}
|
|
3154
3179
|
} else runningObject.push(t__namespace.objectProperty(id, value.expression));
|
|
3155
3180
|
else runningObject.push(t__namespace.objectProperty(id, value));
|
|
3156
3181
|
}
|
|
@@ -3454,6 +3479,7 @@ var config = {
|
|
|
3454
3479
|
builtIns: [],
|
|
3455
3480
|
requireImportSource: false,
|
|
3456
3481
|
wrapConditionals: true,
|
|
3482
|
+
omitNestedClosingTags: false,
|
|
3457
3483
|
contextToCustomElements: false,
|
|
3458
3484
|
staticMarker: "@once",
|
|
3459
3485
|
effectWrapper: "effect",
|
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.
|
|
4
|
+
"version": "0.36.18",
|
|
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": "70ab5bf1b167c0a3cefd0a3582c0b97f502bb92b"
|
|
35
35
|
}
|