babel-plugin-jsx-dom-expressions 0.35.0-beta.1 → 0.35.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 +94 -14
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -57,24 +57,37 @@ const booleans = [
|
|
|
57
57
|
|
|
58
58
|
const BooleanAttributes = /*#__PURE__*/ new Set(booleans);
|
|
59
59
|
|
|
60
|
-
const Properties = /*#__PURE__*/ new Set([
|
|
60
|
+
const Properties = /*#__PURE__*/ new Set([
|
|
61
|
+
"className",
|
|
62
|
+
"value",
|
|
63
|
+
"readOnly",
|
|
64
|
+
"formNoValidate",
|
|
65
|
+
"isMap",
|
|
66
|
+
"noModule",
|
|
67
|
+
"playsInline",
|
|
68
|
+
...booleans
|
|
69
|
+
]);
|
|
61
70
|
|
|
62
|
-
const ChildProperties = /*#__PURE__*/ new Set([
|
|
71
|
+
const ChildProperties = /*#__PURE__*/ new Set([
|
|
72
|
+
"innerHTML",
|
|
73
|
+
"textContent",
|
|
74
|
+
"innerText",
|
|
75
|
+
"children"
|
|
76
|
+
]);
|
|
63
77
|
|
|
64
78
|
// React Compat
|
|
65
|
-
const Aliases = {
|
|
79
|
+
const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
|
|
66
80
|
className: "class",
|
|
67
81
|
htmlFor: "for"
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const PropAliases = {
|
|
82
|
+
});
|
|
83
|
+
const PropAliases = /*#__PURE__*/ Object.assign(Object.create(null), {
|
|
71
84
|
class: "className",
|
|
72
85
|
formnovalidate: "formNoValidate",
|
|
73
86
|
ismap: "isMap",
|
|
74
87
|
nomodule: "noModule",
|
|
75
88
|
playsinline: "playsInline",
|
|
76
89
|
readonly: "readOnly"
|
|
77
|
-
};
|
|
90
|
+
});
|
|
78
91
|
|
|
79
92
|
// list of Element events that will be delegated
|
|
80
93
|
const DelegatedEvents = /*#__PURE__*/ new Set([
|
|
@@ -585,8 +598,27 @@ function transformElement$3(path, info) {
|
|
|
585
598
|
tagName,
|
|
586
599
|
renderer: "dom"
|
|
587
600
|
};
|
|
588
|
-
if (config.hydratable && (tagName === "html" || tagName === "head" || tagName === "body"))
|
|
601
|
+
if (config.hydratable && (tagName === "html" || tagName === "head" || tagName === "body")) {
|
|
589
602
|
results.skipTemplate = true;
|
|
603
|
+
if (tagName === "head" && info.topLevel) {
|
|
604
|
+
const createComponent = registerImportMethod(
|
|
605
|
+
path,
|
|
606
|
+
"createComponent",
|
|
607
|
+
getRendererConfig(path, "dom").moduleName
|
|
608
|
+
);
|
|
609
|
+
const NoHydration = registerImportMethod(
|
|
610
|
+
path,
|
|
611
|
+
"NoHydration",
|
|
612
|
+
getRendererConfig(path, "dom").moduleName
|
|
613
|
+
);
|
|
614
|
+
results.exprs.push(
|
|
615
|
+
t__namespace.expressionStatement(
|
|
616
|
+
t__namespace.callExpression(createComponent, [NoHydration, t__namespace.objectExpression([])])
|
|
617
|
+
)
|
|
618
|
+
);
|
|
619
|
+
return results;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
590
622
|
if (wrapSVG) results.template = "<svg>" + results.template;
|
|
591
623
|
if (!info.skipId) results.id = path.scope.generateUidIdentifier("el$");
|
|
592
624
|
transformAttributes$2(path, results);
|
|
@@ -1197,7 +1229,26 @@ function transformChildren$2(path, results, config) {
|
|
|
1197
1229
|
|
|
1198
1230
|
results.template += child.template;
|
|
1199
1231
|
if (child.id) {
|
|
1200
|
-
if (child.tagName === "head")
|
|
1232
|
+
if (child.tagName === "head") {
|
|
1233
|
+
if (config.hydratable) {
|
|
1234
|
+
const createComponent = registerImportMethod(
|
|
1235
|
+
path,
|
|
1236
|
+
"createComponent",
|
|
1237
|
+
getRendererConfig(path, "dom").moduleName
|
|
1238
|
+
);
|
|
1239
|
+
const NoHydration = registerImportMethod(
|
|
1240
|
+
path,
|
|
1241
|
+
"NoHydration",
|
|
1242
|
+
getRendererConfig(path, "dom").moduleName
|
|
1243
|
+
);
|
|
1244
|
+
results.exprs.push(
|
|
1245
|
+
t__namespace.expressionStatement(
|
|
1246
|
+
t__namespace.callExpression(createComponent, [NoHydration, t__namespace.objectExpression([])])
|
|
1247
|
+
)
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1201
1252
|
|
|
1202
1253
|
let getNextMatch;
|
|
1203
1254
|
if (config.hydratable && tagName === "html") {
|
|
@@ -1408,7 +1459,8 @@ function processSpreads$1(path, attributes, { elem, isSVG, hasChildren, wrapCond
|
|
|
1408
1459
|
const id = convertJSXIdentifier(node.name);
|
|
1409
1460
|
let expr =
|
|
1410
1461
|
wrapConditionals &&
|
|
1411
|
-
(t__namespace.isLogicalExpression(node.value.expression) ||
|
|
1462
|
+
(t__namespace.isLogicalExpression(node.value.expression) ||
|
|
1463
|
+
t__namespace.isConditionalExpression(node.value.expression))
|
|
1412
1464
|
? transformCondition(attribute.get("value").get("expression"), true)
|
|
1413
1465
|
: t__namespace.arrowFunctionExpression([], node.value.expression);
|
|
1414
1466
|
runningObject.push(
|
|
@@ -1724,6 +1776,26 @@ function transformElement$2(path, info) {
|
|
|
1724
1776
|
};
|
|
1725
1777
|
|
|
1726
1778
|
if (info.topLevel && config.hydratable) {
|
|
1779
|
+
if (tagName === "head") {
|
|
1780
|
+
registerImportMethod(path, "NoHydration");
|
|
1781
|
+
registerImportMethod(path, "createComponent");
|
|
1782
|
+
const child = transformElement$2(path, { ...info, topLevel: false });
|
|
1783
|
+
results.template = "";
|
|
1784
|
+
results.exprs.push(
|
|
1785
|
+
t__namespace.callExpression(t__namespace.identifier("_$createComponent"), [
|
|
1786
|
+
t__namespace.identifier("_$NoHydration"),
|
|
1787
|
+
t__namespace.objectExpression([
|
|
1788
|
+
t__namespace.objectMethod(
|
|
1789
|
+
"get",
|
|
1790
|
+
t__namespace.identifier("children"),
|
|
1791
|
+
[],
|
|
1792
|
+
t__namespace.blockStatement([t__namespace.returnStatement(createTemplate$1(path, child))])
|
|
1793
|
+
)
|
|
1794
|
+
])
|
|
1795
|
+
])
|
|
1796
|
+
);
|
|
1797
|
+
return results;
|
|
1798
|
+
}
|
|
1727
1799
|
results.template.push("");
|
|
1728
1800
|
results.templateValues.push(
|
|
1729
1801
|
t__namespace.callExpression(registerImportMethod(path, "ssrHydrationKey"), [])
|
|
@@ -2070,12 +2142,20 @@ function transformChildren$1(path, results, { hydratable }) {
|
|
|
2070
2142
|
filteredChildren.forEach(node => {
|
|
2071
2143
|
if (t__namespace.isJSXElement(node.node) && getTagName(node.node) === "head") {
|
|
2072
2144
|
const child = transformNode(node, { doNotEscape, hydratable: false });
|
|
2073
|
-
registerImportMethod(path, "
|
|
2145
|
+
registerImportMethod(path, "NoHydration");
|
|
2146
|
+
registerImportMethod(path, "createComponent");
|
|
2074
2147
|
results.template.push("");
|
|
2075
2148
|
results.templateValues.push(
|
|
2076
|
-
t__namespace.callExpression(t__namespace.identifier("_$
|
|
2077
|
-
t__namespace.
|
|
2078
|
-
t__namespace.
|
|
2149
|
+
t__namespace.callExpression(t__namespace.identifier("_$createComponent"), [
|
|
2150
|
+
t__namespace.identifier("_$NoHydration"),
|
|
2151
|
+
t__namespace.objectExpression([
|
|
2152
|
+
t__namespace.objectMethod(
|
|
2153
|
+
"get",
|
|
2154
|
+
t__namespace.identifier("children"),
|
|
2155
|
+
[],
|
|
2156
|
+
t__namespace.blockStatement([t__namespace.returnStatement(createTemplate$1(path, child))])
|
|
2157
|
+
)
|
|
2158
|
+
])
|
|
2079
2159
|
])
|
|
2080
2160
|
);
|
|
2081
2161
|
return;
|
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.35.0
|
|
4
|
+
"version": "0.35.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": "e391a71c39e2e6b53ac2ba3b883888b9dbba44e7"
|
|
31
31
|
}
|