babel-plugin-jsx-dom-expressions 0.34.0-beta.0 → 0.34.0
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 +77 -30
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -289,7 +289,11 @@ function isDynamic(path, { checkMember, checkTags, checkCallExpressions = true,
|
|
|
289
289
|
}
|
|
290
290
|
if (
|
|
291
291
|
(checkCallExpressions && t__namespace.isCallExpression(expr)) ||
|
|
292
|
-
(checkMember &&
|
|
292
|
+
(checkMember &&
|
|
293
|
+
(t__namespace.isMemberExpression(expr) ||
|
|
294
|
+
t__namespace.isOptionalMemberExpression(expr) ||
|
|
295
|
+
t__namespace.isSpreadElement(expr) ||
|
|
296
|
+
(t__namespace.isBinaryExpression(expr) && expr.operator === "in"))) ||
|
|
293
297
|
(checkTags && (t__namespace.isJSXElement(expr) || t__namespace.isJSXFragment(expr)))
|
|
294
298
|
)
|
|
295
299
|
return true;
|
|
@@ -314,6 +318,9 @@ function isDynamic(path, { checkMember, checkTags, checkCallExpressions = true,
|
|
|
314
318
|
SpreadElement(p) {
|
|
315
319
|
checkMember && (dynamic = true) && p.stop();
|
|
316
320
|
},
|
|
321
|
+
BinaryExpression(p) {
|
|
322
|
+
checkMember && p.node.operator === "in" && (dynamic = true) && p.stop();
|
|
323
|
+
},
|
|
317
324
|
JSXElement(p) {
|
|
318
325
|
checkTags ? (dynamic = true) && p.stop() : p.skip();
|
|
319
326
|
},
|
|
@@ -541,7 +548,8 @@ function transformElement$3(path, info) {
|
|
|
541
548
|
tagName,
|
|
542
549
|
renderer: "dom"
|
|
543
550
|
};
|
|
544
|
-
if (tagName === "html"
|
|
551
|
+
if (config.hydratable && (tagName === "html" || tagName === "head" || tagName === "body"))
|
|
552
|
+
results.skipTemplate = true;
|
|
545
553
|
if (wrapSVG) results.template = "<svg>" + results.template;
|
|
546
554
|
if (!info.skipId) results.id = path.scope.generateUidIdentifier("el$");
|
|
547
555
|
transformAttributes$2(path, results);
|
|
@@ -884,14 +892,22 @@ function transformAttributes$2(path, results) {
|
|
|
884
892
|
t__namespace.unaryExpression("typeof", refIdentifier),
|
|
885
893
|
t__namespace.stringLiteral("function")
|
|
886
894
|
),
|
|
887
|
-
t__namespace.callExpression(
|
|
895
|
+
t__namespace.callExpression(
|
|
896
|
+
registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
|
|
897
|
+
[refIdentifier, elem]
|
|
898
|
+
),
|
|
888
899
|
t__namespace.assignmentExpression("=", value.expression, elem)
|
|
889
900
|
)
|
|
890
901
|
)
|
|
891
902
|
);
|
|
892
903
|
} else if (isFunction || t__namespace.isFunction(value.expression)) {
|
|
893
904
|
results.exprs.unshift(
|
|
894
|
-
t__namespace.expressionStatement(
|
|
905
|
+
t__namespace.expressionStatement(
|
|
906
|
+
t__namespace.callExpression(
|
|
907
|
+
registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
|
|
908
|
+
[value.expression, elem]
|
|
909
|
+
)
|
|
910
|
+
)
|
|
895
911
|
);
|
|
896
912
|
} else if (t__namespace.isCallExpression(value.expression)) {
|
|
897
913
|
const refIdentifier = path.scope.generateUidIdentifier("_ref$");
|
|
@@ -907,7 +923,10 @@ function transformAttributes$2(path, results) {
|
|
|
907
923
|
t__namespace.unaryExpression("typeof", refIdentifier),
|
|
908
924
|
t__namespace.stringLiteral("function")
|
|
909
925
|
),
|
|
910
|
-
t__namespace.callExpression(
|
|
926
|
+
t__namespace.callExpression(
|
|
927
|
+
registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
|
|
928
|
+
[refIdentifier, elem]
|
|
929
|
+
)
|
|
911
930
|
)
|
|
912
931
|
)
|
|
913
932
|
);
|
|
@@ -917,15 +936,19 @@ function transformAttributes$2(path, results) {
|
|
|
917
936
|
node.name.name.type = "Identifier";
|
|
918
937
|
results.exprs.unshift(
|
|
919
938
|
t__namespace.expressionStatement(
|
|
920
|
-
t__namespace.callExpression(
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
939
|
+
t__namespace.callExpression(
|
|
940
|
+
registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
|
|
941
|
+
[
|
|
942
|
+
node.name.name,
|
|
943
|
+
elem,
|
|
944
|
+
t__namespace.arrowFunctionExpression(
|
|
945
|
+
[],
|
|
946
|
+
t__namespace.isJSXEmptyExpression(value.expression)
|
|
947
|
+
? t__namespace.booleanLiteral(true)
|
|
948
|
+
: value.expression
|
|
949
|
+
)
|
|
950
|
+
]
|
|
951
|
+
)
|
|
929
952
|
)
|
|
930
953
|
);
|
|
931
954
|
} else if (key === "children") {
|
|
@@ -1859,10 +1882,7 @@ function transformAttributes$1(path, results) {
|
|
|
1859
1882
|
if (t__namespace.isJSXExpressionContainer(value)) value = value.expression;
|
|
1860
1883
|
key = toAttribute(key, isSVG);
|
|
1861
1884
|
appendToTemplate(results.template, ` ${key}`);
|
|
1862
|
-
appendToTemplate(
|
|
1863
|
-
results.template,
|
|
1864
|
-
value ? `="${escapeHTML(value.value, true)}"` : BooleanAttributes.has(key) ? "" : "true"
|
|
1865
|
-
);
|
|
1885
|
+
appendToTemplate(results.template, value ? `="${escapeHTML(value.value, true)}"` : "");
|
|
1866
1886
|
}
|
|
1867
1887
|
});
|
|
1868
1888
|
if (!hasChildren && children) {
|
|
@@ -2135,14 +2155,30 @@ function transformAttributes(path, results) {
|
|
|
2135
2155
|
t__namespace.unaryExpression("typeof", refIdentifier),
|
|
2136
2156
|
t__namespace.stringLiteral("function")
|
|
2137
2157
|
),
|
|
2138
|
-
t__namespace.callExpression(
|
|
2158
|
+
t__namespace.callExpression(
|
|
2159
|
+
registerImportMethod(
|
|
2160
|
+
path,
|
|
2161
|
+
"use",
|
|
2162
|
+
getRendererConfig(path, "universal").moduleName
|
|
2163
|
+
),
|
|
2164
|
+
[refIdentifier, elem]
|
|
2165
|
+
),
|
|
2139
2166
|
t__namespace.assignmentExpression("=", value.expression, elem)
|
|
2140
2167
|
)
|
|
2141
2168
|
)
|
|
2142
2169
|
);
|
|
2143
2170
|
} else if (t__namespace.isFunction(value.expression)) {
|
|
2144
2171
|
results.exprs.unshift(
|
|
2145
|
-
t__namespace.expressionStatement(
|
|
2172
|
+
t__namespace.expressionStatement(
|
|
2173
|
+
t__namespace.callExpression(
|
|
2174
|
+
registerImportMethod(
|
|
2175
|
+
path,
|
|
2176
|
+
"use",
|
|
2177
|
+
getRendererConfig(path, "universal").moduleName
|
|
2178
|
+
),
|
|
2179
|
+
[value.expression, elem]
|
|
2180
|
+
)
|
|
2181
|
+
)
|
|
2146
2182
|
);
|
|
2147
2183
|
} else if (t__namespace.isCallExpression(value.expression)) {
|
|
2148
2184
|
const refIdentifier = path.scope.generateUidIdentifier("_ref$");
|
|
@@ -2158,7 +2194,14 @@ function transformAttributes(path, results) {
|
|
|
2158
2194
|
t__namespace.unaryExpression("typeof", refIdentifier),
|
|
2159
2195
|
t__namespace.stringLiteral("function")
|
|
2160
2196
|
),
|
|
2161
|
-
t__namespace.callExpression(
|
|
2197
|
+
t__namespace.callExpression(
|
|
2198
|
+
registerImportMethod(
|
|
2199
|
+
path,
|
|
2200
|
+
"use",
|
|
2201
|
+
getRendererConfig(path, "universal").moduleName
|
|
2202
|
+
),
|
|
2203
|
+
[refIdentifier, elem]
|
|
2204
|
+
)
|
|
2162
2205
|
)
|
|
2163
2206
|
)
|
|
2164
2207
|
);
|
|
@@ -2168,15 +2211,19 @@ function transformAttributes(path, results) {
|
|
|
2168
2211
|
node.name.name.type = "Identifier";
|
|
2169
2212
|
results.exprs.unshift(
|
|
2170
2213
|
t__namespace.expressionStatement(
|
|
2171
|
-
t__namespace.callExpression(
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2214
|
+
t__namespace.callExpression(
|
|
2215
|
+
registerImportMethod(path, "use", getRendererConfig(path, "universal").moduleName),
|
|
2216
|
+
[
|
|
2217
|
+
node.name.name,
|
|
2218
|
+
elem,
|
|
2219
|
+
t__namespace.arrowFunctionExpression(
|
|
2220
|
+
[],
|
|
2221
|
+
t__namespace.isJSXEmptyExpression(value.expression)
|
|
2222
|
+
? t__namespace.booleanLiteral(true)
|
|
2223
|
+
: value.expression
|
|
2224
|
+
)
|
|
2225
|
+
]
|
|
2226
|
+
)
|
|
2180
2227
|
)
|
|
2181
2228
|
);
|
|
2182
2229
|
} else if (key === "children") {
|
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.34.0
|
|
4
|
+
"version": "0.34.0",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@babel/core": "^7.0.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "4a2f5a8af46437c71b0c30a5242213fc87669515"
|
|
31
31
|
}
|