@constela/runtime 2.0.3 → 2.0.4
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/dist/index.js +22 -16
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -16167,20 +16167,22 @@ function hydrateElement(node, el, ctx) {
|
|
|
16167
16167
|
hydrateChildren(node.children, el, ctx);
|
|
16168
16168
|
}
|
|
16169
16169
|
}
|
|
16170
|
-
function
|
|
16171
|
-
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
const text3 =
|
|
16176
|
-
if (text3 === "if:then")
|
|
16177
|
-
|
|
16178
|
-
if (text3 === "if:
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16170
|
+
function collectIfMarkers(parent) {
|
|
16171
|
+
const markers = [];
|
|
16172
|
+
for (let i = 0; i < parent.childNodes.length; i++) {
|
|
16173
|
+
const child = parent.childNodes[i];
|
|
16174
|
+
if (child.nodeType === Node.COMMENT_NODE) {
|
|
16175
|
+
const text3 = child.textContent;
|
|
16176
|
+
if (text3 === "if:then") {
|
|
16177
|
+
markers.push({ branch: "then", marker: child });
|
|
16178
|
+
} else if (text3 === "if:else") {
|
|
16179
|
+
markers.push({ branch: "else", marker: child });
|
|
16180
|
+
} else if (text3 === "if:none") {
|
|
16181
|
+
markers.push({ branch: "none", marker: child });
|
|
16182
|
+
}
|
|
16183
|
+
}
|
|
16182
16184
|
}
|
|
16183
|
-
return
|
|
16185
|
+
return markers;
|
|
16184
16186
|
}
|
|
16185
16187
|
function hydrateChildren(children, parent, ctx) {
|
|
16186
16188
|
const domChildren = [];
|
|
@@ -16190,6 +16192,8 @@ function hydrateChildren(children, parent, ctx) {
|
|
|
16190
16192
|
domChildren.push(child);
|
|
16191
16193
|
}
|
|
16192
16194
|
}
|
|
16195
|
+
const ifMarkers = collectIfMarkers(parent);
|
|
16196
|
+
let ifMarkerIndex = 0;
|
|
16193
16197
|
let domIndex = 0;
|
|
16194
16198
|
for (let i = 0; i < children.length; i++) {
|
|
16195
16199
|
const childNode = children[i];
|
|
@@ -16224,14 +16228,15 @@ function hydrateChildren(children, parent, ctx) {
|
|
|
16224
16228
|
...ctx.route && { route: ctx.route }
|
|
16225
16229
|
});
|
|
16226
16230
|
const clientBranch = Boolean(clientCondition) ? "then" : ifNode.else ? "else" : "none";
|
|
16227
|
-
const
|
|
16228
|
-
|
|
16231
|
+
const ssrInfo = ifMarkerIndex < ifMarkers.length ? ifMarkers[ifMarkerIndex] : null;
|
|
16232
|
+
ifMarkerIndex++;
|
|
16229
16233
|
const ssrBranch = ssrInfo?.branch ?? null;
|
|
16230
16234
|
const ssrHasDom = ssrBranch === "then" || ssrBranch === "else";
|
|
16231
16235
|
if (ssrInfo?.marker) {
|
|
16232
16236
|
ssrInfo.marker.remove();
|
|
16233
16237
|
}
|
|
16234
|
-
if (ssrHasDom &&
|
|
16238
|
+
if (ssrHasDom && domChildren[domIndex]) {
|
|
16239
|
+
const domChild = domChildren[domIndex];
|
|
16235
16240
|
hydrateIf(ifNode, domChild, ctx, { ssrBranch, clientBranch });
|
|
16236
16241
|
domIndex++;
|
|
16237
16242
|
} else if (ssrBranch === "none") {
|
|
@@ -16240,6 +16245,7 @@ function hydrateChildren(children, parent, ctx) {
|
|
|
16240
16245
|
});
|
|
16241
16246
|
} else {
|
|
16242
16247
|
const hasDomForIf = Boolean(clientCondition) || Boolean(ifNode.else);
|
|
16248
|
+
const domChild = domChildren[domIndex];
|
|
16243
16249
|
if (hasDomForIf && domChild) {
|
|
16244
16250
|
hydrate(childNode, domChild, ctx);
|
|
16245
16251
|
domIndex++;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/runtime",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Runtime DOM renderer for Constela UI framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"dompurify": "^3.3.1",
|
|
19
19
|
"marked": "^17.0.1",
|
|
20
20
|
"shiki": "^3.20.0",
|
|
21
|
-
"@constela/
|
|
22
|
-
"@constela/
|
|
21
|
+
"@constela/compiler": "0.15.8",
|
|
22
|
+
"@constela/core": "0.18.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/dompurify": "^3.2.0",
|