kerfjs 5.0.0-beta.12 → 5.0.0-beta.121
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/CHANGELOG.md +2987 -107
- package/README.md +96 -37
- package/ai/cursorrules +111 -62
- package/ai/manifest.json +30 -7
- package/ai/skill.md +149 -77
- package/ai/ui-skill.md +18 -0
- package/dist/actions.d.ts +1 -1
- package/dist/actions.js +10 -6
- package/dist/actions.js.map +1 -1
- package/dist/array-signal.js +1 -1
- package/dist/async.js +24 -21
- package/dist/async.js.map +1 -1
- package/dist/attach.js +1 -66
- package/dist/attach.js.map +1 -1
- package/dist/{chunk-HW7KSM2Y.js → chunk-3C6F6NM4.js} +1 -1
- package/dist/{chunk-HW7KSM2Y.js.map → chunk-3C6F6NM4.js.map} +1 -1
- package/dist/{chunk-GY4XV2UV.js → chunk-4TX6YJDM.js} +10 -3
- package/dist/chunk-4TX6YJDM.js.map +1 -0
- package/dist/{chunk-QIP723L4.js → chunk-5WRGJZV6.js} +3 -2
- package/dist/chunk-5WRGJZV6.js.map +1 -0
- package/dist/{chunk-V46JKE44.js → chunk-6LXUC4ZY.js} +29 -2
- package/dist/chunk-6LXUC4ZY.js.map +1 -0
- package/dist/{chunk-KZJXHFIB.js → chunk-BI4HGICV.js} +3 -3
- package/dist/chunk-BI4HGICV.js.map +1 -0
- package/dist/chunk-FM6N2B4N.js +70 -0
- package/dist/chunk-FM6N2B4N.js.map +1 -0
- package/dist/{chunk-LVH3GC6B.js → chunk-H7WTRM6F.js} +3 -3
- package/dist/chunk-H7WTRM6F.js.map +1 -0
- package/dist/{chunk-U6FK33SG.js → chunk-IHMDBBUJ.js} +2 -2
- package/dist/chunk-IHMDBBUJ.js.map +1 -0
- package/dist/chunk-JN7EJM3B.js +86 -0
- package/dist/chunk-JN7EJM3B.js.map +1 -0
- package/dist/{chunk-UZJ6I4T6.js → chunk-MK42GLPV.js} +1 -1
- package/dist/chunk-MK42GLPV.js.map +1 -0
- package/dist/{chunk-ZDCJZCNO.js → chunk-VX3RCRGG.js} +161 -90
- package/dist/chunk-VX3RCRGG.js.map +1 -0
- package/dist/{chunk-SVATPF5R.js → chunk-YVBK73GU.js} +612 -178
- package/dist/chunk-YVBK73GU.js.map +1 -0
- package/dist/{delegate-CL9VTZFb.d.ts → delegate--CrfgYtC.d.ts} +0 -34
- package/dist/dev.d.ts +31 -13
- package/dist/dev.js +101 -35
- package/dist/dev.js.map +1 -1
- package/dist/html.js +20 -8
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +14 -9
- package/dist/index.js +29 -20
- package/dist/index.js.map +1 -1
- package/dist/jsx-runtime.d.ts +22 -7
- package/dist/jsx-runtime.js +1 -1
- package/dist/list.d.ts +7 -3
- package/dist/list.js +153 -46
- package/dist/list.js.map +1 -1
- package/dist/overlay.d.ts +278 -133
- package/dist/overlay.js +1034 -368
- package/dist/overlay.js.map +1 -1
- package/dist/remount.js +2 -2
- package/dist/router.d.ts +13 -4
- package/dist/router.js +37 -10
- package/dist/router.js.map +1 -1
- package/dist/scope.d.ts +35 -8
- package/dist/scope.js +61 -30
- package/dist/scope.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/timing.d.ts +3 -2
- package/dist/timing.js +1 -1
- package/dist/timing.js.map +1 -1
- package/llms.txt +14 -6
- package/package.json +44 -12
- package/setup/cli.mjs +94 -0
- package/setup/index.d.mts +38 -0
- package/setup/index.mjs +1553 -0
- package/setup/jsonc.mjs +201 -0
- package/setup/state.schema.json +57 -0
- package/setup/ui-baseline.mjs +210 -0
- package/dist/chunk-GY4XV2UV.js.map +0 -1
- package/dist/chunk-KPXIOG2C.js +0 -54
- package/dist/chunk-KPXIOG2C.js.map +0 -1
- package/dist/chunk-KZJXHFIB.js.map +0 -1
- package/dist/chunk-LVH3GC6B.js.map +0 -1
- package/dist/chunk-QIP723L4.js.map +0 -1
- package/dist/chunk-SVATPF5R.js.map +0 -1
- package/dist/chunk-U6FK33SG.js.map +0 -1
- package/dist/chunk-UZJ6I4T6.js.map +0 -1
- package/dist/chunk-V46JKE44.js.map +0 -1
- package/dist/chunk-ZDCJZCNO.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { itemVersion } from './chunk-
|
|
2
|
-
import { parseRowTemplate, rowContractError, parseSingleRow, collectTemplateChildren } from './chunk-
|
|
3
|
-
import { captureRowBindings, listSafeHtml, boundTextNodeOf, syncFormProp, newBindingContext,
|
|
4
|
-
import { effect } from './chunk-
|
|
5
|
-
import { LIST_MARKER_PREFIX, flattenWithoutListItems, collectLists, flatten } from './chunk-
|
|
6
|
-
import { devHooks } from './chunk-
|
|
1
|
+
import { itemVersion } from './chunk-5WRGJZV6.js';
|
|
2
|
+
import { seedRenderedAttrs, RENDERED_ATTRS, isUserAgentOwnedAttr, hasCustomTag, parseRowTemplate, rowContractError, parseSingleRow, collectTemplateChildren } from './chunk-6LXUC4ZY.js';
|
|
3
|
+
import { captureRowBindings, listSafeHtml, boundTextNodeOf, syncFormProp, newBindingContext, wireBindings, disposeRowBindings, isSafeHtml, _setBindingContext, TEXT_MARKER_PREFIX, ROW_TEXT_PREFIX, wireRowBindings, carryOrRewireRowBindings, granularListSafeHtml } from './chunk-VX3RCRGG.js';
|
|
4
|
+
import { effect } from './chunk-IHMDBBUJ.js';
|
|
5
|
+
import { LIST_MARKER_PREFIX, flattenWithoutListItems, collectLists, isOverlayHost, flatten } from './chunk-4TX6YJDM.js';
|
|
6
|
+
import { devHooks } from './chunk-3C6F6NM4.js';
|
|
7
7
|
|
|
8
8
|
// src/list-render-state.ts
|
|
9
9
|
function deriveListRenderState(bindingCount) {
|
|
@@ -18,7 +18,8 @@ function decideListPath(state, patches, snapshotLength, previousBindingCount) {
|
|
|
18
18
|
for (const p of patches) {
|
|
19
19
|
if (p.type === "insert") netDelta += 1;
|
|
20
20
|
else if (p.type === "remove") netDelta -= 1;
|
|
21
|
-
else if (p.type === "replace")
|
|
21
|
+
else if (p.type === "replace")
|
|
22
|
+
return { path: "snapshot", reason: "replace" };
|
|
22
23
|
}
|
|
23
24
|
const count = previousBindingCount ?? 0;
|
|
24
25
|
if (count + netDelta !== snapshotLength) {
|
|
@@ -110,11 +111,18 @@ function _hasGranularIndexShift(previousBindingCount, patches) {
|
|
|
110
111
|
const rendered = [];
|
|
111
112
|
for (let i = 0; i < previousBindingCount; i++) rendered.push(i);
|
|
112
113
|
for (const patch of patches) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
switch (patch.type) {
|
|
115
|
+
case "insert":
|
|
116
|
+
rendered.splice(patch.index, 0, patch.index);
|
|
117
|
+
break;
|
|
118
|
+
case "remove":
|
|
119
|
+
rendered.splice(patch.index, 1);
|
|
120
|
+
break;
|
|
121
|
+
case "move": {
|
|
122
|
+
const [moved] = rendered.splice(patch.from, 1);
|
|
123
|
+
rendered.splice(patch.to, 0, moved);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
118
126
|
}
|
|
119
127
|
}
|
|
120
128
|
return rendered.some((renderedAt, index) => renderedAt !== index);
|
|
@@ -153,10 +161,12 @@ function eachGranular(sig, render, cacheKey, listKey) {
|
|
|
153
161
|
return eachSnapshotById(snapshot, render, cacheKey, id, sig);
|
|
154
162
|
}
|
|
155
163
|
}
|
|
156
|
-
const renderRow = (item, index) => captureRowBindings(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
const renderRow = (item, index) => captureRowBindings(
|
|
165
|
+
() => inRowScope(() => {
|
|
166
|
+
const out = render(item, index);
|
|
167
|
+
return isSafeHtml(out) ? out.toString() : out;
|
|
168
|
+
})
|
|
169
|
+
);
|
|
160
170
|
const internalPatches = new Array(patches.length);
|
|
161
171
|
const cache = ctx.caches.get(id);
|
|
162
172
|
try {
|
|
@@ -223,13 +233,16 @@ function eachSnapshotById(items, render, cacheKey, id, source) {
|
|
|
223
233
|
devHooks.staleIndex?.(id);
|
|
224
234
|
}
|
|
225
235
|
} else {
|
|
226
|
-
const captured = captureRowBindings(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
236
|
+
const captured = captureRowBindings(
|
|
237
|
+
() => inRowScope(() => {
|
|
238
|
+
const out = render(item, i);
|
|
239
|
+
return isSafeHtml(out) ? out.toString() : out;
|
|
240
|
+
})
|
|
241
|
+
);
|
|
230
242
|
html = captured.html;
|
|
231
243
|
bindings = captured.bindings;
|
|
232
|
-
if (cache !== null)
|
|
244
|
+
if (cache !== null)
|
|
245
|
+
cache.set(item, { cacheKey: k, html, bindings, version, index: i });
|
|
233
246
|
}
|
|
234
247
|
segItems[i] = { ref: item, cacheKey: k, html, bindings };
|
|
235
248
|
}
|
|
@@ -281,12 +294,7 @@ function restoreFocus(snap) {
|
|
|
281
294
|
if (domSelection === null) return;
|
|
282
295
|
const [anchorNode, anchorOffset, focusNode, focusOffset] = domSelection;
|
|
283
296
|
try {
|
|
284
|
-
document.getSelection()?.setBaseAndExtent(
|
|
285
|
-
anchorNode,
|
|
286
|
-
anchorOffset,
|
|
287
|
-
focusNode,
|
|
288
|
-
focusOffset
|
|
289
|
-
);
|
|
297
|
+
document.getSelection()?.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
290
298
|
} catch {
|
|
291
299
|
}
|
|
292
300
|
}
|
|
@@ -343,7 +351,11 @@ function protectionTag(node) {
|
|
|
343
351
|
const { dataset } = node;
|
|
344
352
|
return (dataset.morphSkip !== void 0 ? "s" : "") + (dataset.morphSkipChildren !== void 0 ? "c" : "") + (dataset.morphPreserve !== void 0 ? "p" : "");
|
|
345
353
|
}
|
|
346
|
-
var MARKER_PREFIXES = [
|
|
354
|
+
var MARKER_PREFIXES = [
|
|
355
|
+
LIST_MARKER_PREFIX,
|
|
356
|
+
TEXT_MARKER_PREFIX,
|
|
357
|
+
ROW_TEXT_PREFIX
|
|
358
|
+
];
|
|
347
359
|
function isMarker(node) {
|
|
348
360
|
if (node.nodeType !== COMMENT_NODE) return false;
|
|
349
361
|
const { data } = node;
|
|
@@ -421,7 +433,8 @@ function morphChildren(fromParent, toParent, ownedItems) {
|
|
|
421
433
|
if (matched === null && fromChild !== null && toChild.nodeType === COMMENT_NODE && toChild.data.startsWith(LIST_MARKER_PREFIX)) {
|
|
422
434
|
const wantData = toChild.data;
|
|
423
435
|
for (let scan = fromChild.nextSibling; scan !== null; scan = scan.nextSibling) {
|
|
424
|
-
if (scan.nodeType !== COMMENT_NODE || scan.data !== wantData)
|
|
436
|
+
if (scan.nodeType !== COMMENT_NODE || scan.data !== wantData)
|
|
437
|
+
continue;
|
|
425
438
|
const regionEnd = afterListRegion(scan, ownedItems);
|
|
426
439
|
const run = [];
|
|
427
440
|
for (let r = scan; r !== null && r !== regionEnd; r = r.nextSibling) {
|
|
@@ -438,6 +451,9 @@ function morphChildren(fromParent, toParent, ownedItems) {
|
|
|
438
451
|
morphNode(matched, toChild, ownedItems);
|
|
439
452
|
} else {
|
|
440
453
|
const cloned = toChild.cloneNode(true);
|
|
454
|
+
if (toChild.nodeType === ELEMENT_NODE) {
|
|
455
|
+
seedRenderedAttrs(toChild, cloned);
|
|
456
|
+
}
|
|
441
457
|
fromParent.insertBefore(cloned, fromChild);
|
|
442
458
|
}
|
|
443
459
|
toChild = toNext;
|
|
@@ -469,6 +485,7 @@ function morphNode(fromNode, toNode, ownedItems) {
|
|
|
469
485
|
function morphElement(fromEl, toEl, ownedItems) {
|
|
470
486
|
if (fromEl.tagName !== toEl.tagName) {
|
|
471
487
|
const replacement = toEl.cloneNode(true);
|
|
488
|
+
seedRenderedAttrs(toEl, replacement);
|
|
472
489
|
fromEl.parentNode?.replaceChild(replacement, fromEl);
|
|
473
490
|
return;
|
|
474
491
|
}
|
|
@@ -487,10 +504,10 @@ function morphElement(fromEl, toEl, ownedItems) {
|
|
|
487
504
|
fromEl.value = toEl.textContent;
|
|
488
505
|
}
|
|
489
506
|
}
|
|
490
|
-
function isUserAgentOwnedAttr(tagName, name) {
|
|
491
|
-
return name === "open" && (tagName === "DETAILS" || tagName === "DIALOG");
|
|
492
|
-
}
|
|
493
507
|
function morphAttributes(fromEl, toEl) {
|
|
508
|
+
const fromTag = fromEl.tagName;
|
|
509
|
+
const host = fromEl;
|
|
510
|
+
const rendered = host[RENDERED_ATTRS];
|
|
494
511
|
const toAttrs = toEl.attributes;
|
|
495
512
|
for (let i = 0; i < toAttrs.length; i++) {
|
|
496
513
|
const attr = toAttrs[i];
|
|
@@ -507,18 +524,18 @@ function morphAttributes(fromEl, toEl) {
|
|
|
507
524
|
}
|
|
508
525
|
}
|
|
509
526
|
const fromAttrs = fromEl.attributes;
|
|
510
|
-
const fromTag = fromEl.tagName;
|
|
511
527
|
for (let i = fromAttrs.length - 1; i >= 0; i--) {
|
|
512
528
|
const attr = fromAttrs[i];
|
|
513
529
|
const ns = attr.namespaceURI;
|
|
514
530
|
const name = attr.localName;
|
|
515
531
|
if (ns !== null) {
|
|
516
532
|
if (!toEl.hasAttributeNS(ns, name)) fromEl.removeAttributeNS(ns, name);
|
|
517
|
-
} else if (!toEl.hasAttribute(name) && !isUserAgentOwnedAttr(fromTag, name)) {
|
|
533
|
+
} else if (!toEl.hasAttribute(name) && !isUserAgentOwnedAttr(fromTag, name) && (!rendered || rendered.includes(name))) {
|
|
518
534
|
fromEl.removeAttribute(name);
|
|
519
535
|
syncFormProp(fromEl, name, "", false);
|
|
520
536
|
}
|
|
521
537
|
}
|
|
538
|
+
if (fromTag.includes("-")) host[RENDERED_ATTRS] = toEl.getAttributeNames();
|
|
522
539
|
}
|
|
523
540
|
function isTextInputOrTextarea(el) {
|
|
524
541
|
if (el.tagName === "TEXTAREA") return true;
|
|
@@ -534,7 +551,10 @@ function preserveTextEntryState(fromEl, toEl) {
|
|
|
534
551
|
const toInput = toEl;
|
|
535
552
|
toInput.value = fromInput.value;
|
|
536
553
|
try {
|
|
537
|
-
toInput.setSelectionRange(
|
|
554
|
+
toInput.setSelectionRange(
|
|
555
|
+
fromInput.selectionStart,
|
|
556
|
+
fromInput.selectionEnd
|
|
557
|
+
);
|
|
538
558
|
} catch {
|
|
539
559
|
}
|
|
540
560
|
}
|
|
@@ -567,7 +587,8 @@ function tryAttributeOnlyFastPath(liveNode, oldHtml, newHtml) {
|
|
|
567
587
|
if (oldGt === -1 || newGt === -1) return false;
|
|
568
588
|
if (oldHtml.length - oldGt !== newHtml.length - newGt) return false;
|
|
569
589
|
if (oldHtml.slice(oldGt) !== newHtml.slice(newGt)) return false;
|
|
570
|
-
if (containsDataMorphSkip(oldHtml) || containsDataMorphSkip(newHtml))
|
|
590
|
+
if (containsDataMorphSkip(oldHtml) || containsDataMorphSkip(newHtml))
|
|
591
|
+
return false;
|
|
571
592
|
const oldTag = parseOpeningTag(oldHtml, oldGt);
|
|
572
593
|
const newTag = parseOpeningTag(newHtml, newGt);
|
|
573
594
|
if (oldTag === null || newTag === null) return false;
|
|
@@ -588,14 +609,16 @@ function tryAttributeOnlyFastPath(liveNode, oldHtml, newHtml) {
|
|
|
588
609
|
}
|
|
589
610
|
for (const name of oldTag.attrs.keys()) {
|
|
590
611
|
if (newTag.attrs.has(name)) continue;
|
|
591
|
-
if (
|
|
612
|
+
if (isUserAgentOwnedAttr(liveTagUpper, name)) continue;
|
|
592
613
|
liveNode.removeAttribute(name);
|
|
593
614
|
syncFormProp(liveNode, name, "", false);
|
|
594
615
|
}
|
|
616
|
+
delete liveNode[RENDERED_ATTRS];
|
|
595
617
|
return true;
|
|
596
618
|
}
|
|
597
619
|
function tryTextContentFastPath(liveNode, oldHtml, newHtml) {
|
|
598
|
-
if (containsDataMorphSkip(oldHtml) || containsDataMorphSkip(newHtml))
|
|
620
|
+
if (containsDataMorphSkip(oldHtml) || containsDataMorphSkip(newHtml))
|
|
621
|
+
return false;
|
|
599
622
|
let p = 0;
|
|
600
623
|
const minLen = Math.min(oldHtml.length, newHtml.length);
|
|
601
624
|
while (p < minLen && oldHtml.charCodeAt(p) === newHtml.charCodeAt(p)) p++;
|
|
@@ -610,7 +633,8 @@ function tryTextContentFastPath(liveNode, oldHtml, newHtml) {
|
|
|
610
633
|
if (!isPureTextWindow(newHtml, p, newWinEnd)) return false;
|
|
611
634
|
if (p === 0) return false;
|
|
612
635
|
const boundaryCc = oldHtml.charCodeAt(p - 1);
|
|
613
|
-
if (boundaryCc === LT || boundaryCc === DQUOTE || boundaryCc === SQUOTE || boundaryCc === EQ || boundaryCc === AMP)
|
|
636
|
+
if (boundaryCc === LT || boundaryCc === DQUOTE || boundaryCc === SQUOTE || boundaryCc === EQ || boundaryCc === AMP)
|
|
637
|
+
return false;
|
|
614
638
|
const textStart = lastIndexOfChar(oldHtml, GT, p - 1);
|
|
615
639
|
if (textStart === -1) return false;
|
|
616
640
|
const textEnd = oldHtml.indexOf("<", p);
|
|
@@ -637,7 +661,8 @@ function containsDataMorphSkip(html) {
|
|
|
637
661
|
function isPureTextWindow(html, start, end) {
|
|
638
662
|
for (let i = start; i < end; i++) {
|
|
639
663
|
const cc = html.charCodeAt(i);
|
|
640
|
-
if (cc === LT || cc === GT || cc === DQUOTE || cc === SQUOTE || cc === AMP || cc === EQ)
|
|
664
|
+
if (cc === LT || cc === GT || cc === DQUOTE || cc === SQUOTE || cc === AMP || cc === EQ)
|
|
665
|
+
return false;
|
|
641
666
|
}
|
|
642
667
|
return true;
|
|
643
668
|
}
|
|
@@ -730,9 +755,6 @@ function unescapeAttrValue(s) {
|
|
|
730
755
|
if (s.indexOf("&") === -1) return s;
|
|
731
756
|
return s.replace(/"/g, '"').replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
732
757
|
}
|
|
733
|
-
function isUserAgentOwnedAttr2(tagNameUpper, name) {
|
|
734
|
-
return name === "open" && (tagNameUpper === "DETAILS" || tagNameUpper === "DIALOG");
|
|
735
|
-
}
|
|
736
758
|
|
|
737
759
|
// src/list-reconcile-granular.ts
|
|
738
760
|
function reconcileGranular(binding, patches) {
|
|
@@ -769,7 +791,14 @@ function reconcileGranular(binding, patches) {
|
|
|
769
791
|
if (runLen === 1) {
|
|
770
792
|
applySingleInsert(liveParent, items, patch, endAnchor(binding));
|
|
771
793
|
} else {
|
|
772
|
-
applyBulkInsert(
|
|
794
|
+
applyBulkInsert(
|
|
795
|
+
liveParent,
|
|
796
|
+
items,
|
|
797
|
+
patches,
|
|
798
|
+
i,
|
|
799
|
+
runEnd,
|
|
800
|
+
endAnchor(binding)
|
|
801
|
+
);
|
|
773
802
|
}
|
|
774
803
|
i = runEnd;
|
|
775
804
|
continue;
|
|
@@ -881,7 +910,10 @@ function applyBulkUpdate(liveParent, items, patches, start, end) {
|
|
|
881
910
|
morphChanges.push({ patchIdx: k, html: p.html });
|
|
882
911
|
}
|
|
883
912
|
if (morphChanges.length === 0) return;
|
|
884
|
-
const { content, count } = parseRowTemplate(
|
|
913
|
+
const { content, count } = parseRowTemplate(
|
|
914
|
+
morphChanges.map((c) => c.html).join(""),
|
|
915
|
+
liveParent
|
|
916
|
+
);
|
|
885
917
|
if (count !== morphChanges.length) {
|
|
886
918
|
throw findOffendingChange(patches, morphChanges, liveParent);
|
|
887
919
|
}
|
|
@@ -924,18 +956,30 @@ function applyBulkInsert(liveParent, items, patches, start, end, tailAnchor) {
|
|
|
924
956
|
function findOffendingInsert(patches, start, htmls, liveParent) {
|
|
925
957
|
for (let i = 0; i < htmls.length; i++) {
|
|
926
958
|
if (parseRowTemplate(htmls[i], liveParent).count !== 1) {
|
|
927
|
-
return rowContractError(
|
|
959
|
+
return rowContractError(
|
|
960
|
+
patches[start + i].index,
|
|
961
|
+
htmls[i],
|
|
962
|
+
liveParent
|
|
963
|
+
);
|
|
928
964
|
}
|
|
929
965
|
}
|
|
930
|
-
return new Error(
|
|
966
|
+
return new Error(
|
|
967
|
+
"each(): bulk-insert mismatch with no per-row offender (kerf bug)."
|
|
968
|
+
);
|
|
931
969
|
}
|
|
932
970
|
function findOffendingChange(patches, changes, liveParent) {
|
|
933
971
|
for (const c of changes) {
|
|
934
972
|
if (parseRowTemplate(c.html, liveParent).count !== 1) {
|
|
935
|
-
return rowContractError(
|
|
973
|
+
return rowContractError(
|
|
974
|
+
patches[c.patchIdx].index,
|
|
975
|
+
c.html,
|
|
976
|
+
liveParent
|
|
977
|
+
);
|
|
936
978
|
}
|
|
937
979
|
}
|
|
938
|
-
return new Error(
|
|
980
|
+
return new Error(
|
|
981
|
+
"each(): bulk-update mismatch with no per-row offender (kerf bug)."
|
|
982
|
+
);
|
|
939
983
|
}
|
|
940
984
|
|
|
941
985
|
// src/list-reconcile-inplace.ts
|
|
@@ -958,9 +1002,14 @@ function tryInPlaceContentUpdate(binding, listSeg) {
|
|
|
958
1002
|
devHooks.missingRowKey?.(newRecord[0].node, newRecord[0].html, binding);
|
|
959
1003
|
return true;
|
|
960
1004
|
}
|
|
961
|
-
function updateRowInPlace(liveParent, old, ni, index) {
|
|
1005
|
+
function updateRowInPlace(liveParent, old, ni, index, parsedNode) {
|
|
962
1006
|
if (old.html === ni.html || tryAttributeOnlyFastPath(old.node, old.html, ni.html) || tryTextContentFastPath(old.node, old.html, ni.html)) {
|
|
963
|
-
const kept = carryOrRewireRowBindings(
|
|
1007
|
+
const kept = carryOrRewireRowBindings(
|
|
1008
|
+
old.node,
|
|
1009
|
+
old.bindings,
|
|
1010
|
+
old.bindingDisposers,
|
|
1011
|
+
ni.bindings
|
|
1012
|
+
);
|
|
964
1013
|
return {
|
|
965
1014
|
ref: ni.ref,
|
|
966
1015
|
cacheKey: ni.cacheKey,
|
|
@@ -970,10 +1019,15 @@ function updateRowInPlace(liveParent, old, ni, index) {
|
|
|
970
1019
|
bindingDisposers: kept.bindingDisposers
|
|
971
1020
|
};
|
|
972
1021
|
}
|
|
973
|
-
const newNode = parseSingleRow(ni.html, index, liveParent);
|
|
1022
|
+
const newNode = parsedNode ?? parseSingleRow(ni.html, index, liveParent);
|
|
974
1023
|
if (old.node.tagName === newNode.tagName) {
|
|
975
1024
|
_morphElement(old.node, newNode);
|
|
976
|
-
const kept = carryOrRewireRowBindings(
|
|
1025
|
+
const kept = carryOrRewireRowBindings(
|
|
1026
|
+
old.node,
|
|
1027
|
+
old.bindings,
|
|
1028
|
+
old.bindingDisposers,
|
|
1029
|
+
ni.bindings
|
|
1030
|
+
);
|
|
977
1031
|
return {
|
|
978
1032
|
ref: ni.ref,
|
|
979
1033
|
cacheKey: ni.cacheKey,
|
|
@@ -985,7 +1039,12 @@ function updateRowInPlace(liveParent, old, ni, index) {
|
|
|
985
1039
|
}
|
|
986
1040
|
disposeRowBindings(old.bindingDisposers);
|
|
987
1041
|
liveParent.replaceChild(newNode, old.node);
|
|
988
|
-
const fresh = carryOrRewireRowBindings(
|
|
1042
|
+
const fresh = carryOrRewireRowBindings(
|
|
1043
|
+
newNode,
|
|
1044
|
+
void 0,
|
|
1045
|
+
void 0,
|
|
1046
|
+
ni.bindings
|
|
1047
|
+
);
|
|
989
1048
|
return {
|
|
990
1049
|
ref: ni.ref,
|
|
991
1050
|
cacheKey: ni.cacheKey,
|
|
@@ -1004,6 +1063,15 @@ function reconcileSnapshot(binding, listSeg) {
|
|
|
1004
1063
|
const tailAnchor = endAnchor(binding);
|
|
1005
1064
|
buildFreshNodes(newRecord, freshIndices, freshHtmls, liveParent);
|
|
1006
1065
|
const focusSnap = captureFocus(liveParent);
|
|
1066
|
+
reuseKeyedRows(
|
|
1067
|
+
binding.items,
|
|
1068
|
+
listSeg,
|
|
1069
|
+
newRecord,
|
|
1070
|
+
prevIdx,
|
|
1071
|
+
removedItems,
|
|
1072
|
+
freshIndices,
|
|
1073
|
+
liveParent
|
|
1074
|
+
);
|
|
1007
1075
|
removeOldNodes(liveParent, removedItems);
|
|
1008
1076
|
applyMoves(liveParent, newRecord, prevIdx, lis(prevIdx), tailAnchor);
|
|
1009
1077
|
if (focusSnap !== null) restoreFocus(focusSnap);
|
|
@@ -1012,6 +1080,47 @@ function reconcileSnapshot(binding, listSeg) {
|
|
|
1012
1080
|
devHooks.missingRowKey?.(newRecord[0].node, newRecord[0].html, binding);
|
|
1013
1081
|
}
|
|
1014
1082
|
}
|
|
1083
|
+
function reuseKeyedRows(oldItems, listSeg, newRecord, prevIdx, removedItems, freshIndices, liveParent) {
|
|
1084
|
+
if (freshIndices.length === 0 || removedItems.length === 0) return;
|
|
1085
|
+
const oldByKey = /* @__PURE__ */ new Map();
|
|
1086
|
+
for (let index = 0; index < oldItems.length; index++) {
|
|
1087
|
+
const key = getNodeKey(oldItems[index].node);
|
|
1088
|
+
if (key === void 0) continue;
|
|
1089
|
+
oldByKey.set(
|
|
1090
|
+
key,
|
|
1091
|
+
oldByKey.has(key) ? null : { item: oldItems[index], index }
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
const newKeyCounts = /* @__PURE__ */ new Map();
|
|
1095
|
+
for (const item of newRecord) {
|
|
1096
|
+
const key = getNodeKey(item.node);
|
|
1097
|
+
if (key !== void 0)
|
|
1098
|
+
newKeyCounts.set(key, (newKeyCounts.get(key) ?? 0) + 1);
|
|
1099
|
+
}
|
|
1100
|
+
const removedSet = new Set(removedItems);
|
|
1101
|
+
const reused = /* @__PURE__ */ new Set();
|
|
1102
|
+
for (const index of freshIndices) {
|
|
1103
|
+
const fresh = newRecord[index];
|
|
1104
|
+
const key = getNodeKey(fresh.node);
|
|
1105
|
+
if (key === void 0 || newKeyCounts.get(key) !== 1) continue;
|
|
1106
|
+
const prior = oldByKey.get(key);
|
|
1107
|
+
if (prior === void 0 || prior === null || !removedSet.has(prior.item) || prior.item.node.tagName !== fresh.node.tagName)
|
|
1108
|
+
continue;
|
|
1109
|
+
disposeRowBindings(fresh.bindingDisposers);
|
|
1110
|
+
newRecord[index] = updateRowInPlace(
|
|
1111
|
+
liveParent,
|
|
1112
|
+
prior.item,
|
|
1113
|
+
listSeg.items[index],
|
|
1114
|
+
index,
|
|
1115
|
+
fresh.node
|
|
1116
|
+
);
|
|
1117
|
+
prevIdx[index] = prior.index;
|
|
1118
|
+
reused.add(prior.item);
|
|
1119
|
+
}
|
|
1120
|
+
for (let i = removedItems.length - 1; i >= 0; i--) {
|
|
1121
|
+
if (reused.has(removedItems[i])) removedItems.splice(i, 1);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1015
1124
|
function classifyItems(oldItems, listSeg) {
|
|
1016
1125
|
const oldByRef = /* @__PURE__ */ new Map();
|
|
1017
1126
|
for (let i = 0; i < oldItems.length; i++) {
|
|
@@ -1070,15 +1179,22 @@ function buildFreshNodes(newRecord, freshIndices, freshHtmls, liveParent) {
|
|
|
1070
1179
|
function findOffendingRow(newRecord, freshIndices, freshHtmls, liveParent) {
|
|
1071
1180
|
for (let i = 0; i < freshHtmls.length; i++) {
|
|
1072
1181
|
if (parseRowTemplate(freshHtmls[i], liveParent).count !== 1) {
|
|
1073
|
-
return rowContractError(
|
|
1182
|
+
return rowContractError(
|
|
1183
|
+
freshIndices[i],
|
|
1184
|
+
newRecord[freshIndices[i]].html,
|
|
1185
|
+
liveParent
|
|
1186
|
+
);
|
|
1074
1187
|
}
|
|
1075
1188
|
}
|
|
1076
|
-
return new Error(
|
|
1189
|
+
return new Error(
|
|
1190
|
+
"each(): bulk-parse mismatch with no per-row offender (kerf bug)."
|
|
1191
|
+
);
|
|
1077
1192
|
}
|
|
1078
1193
|
function removeOldNodes(liveParent, removedItems) {
|
|
1079
1194
|
for (const item of removedItems) {
|
|
1080
1195
|
disposeRowBindings(item.bindingDisposers);
|
|
1081
|
-
if (item.node.parentElement === liveParent)
|
|
1196
|
+
if (item.node.parentElement === liveParent)
|
|
1197
|
+
liveParent.removeChild(item.node);
|
|
1082
1198
|
}
|
|
1083
1199
|
}
|
|
1084
1200
|
function applyMoves(liveParent, newRecord, prevIdx, stable, tailAnchor) {
|
|
@@ -1130,6 +1246,365 @@ function reconcileList(binding, listSeg) {
|
|
|
1130
1246
|
reconcileSnapshot(binding, listSeg);
|
|
1131
1247
|
}
|
|
1132
1248
|
|
|
1249
|
+
// src/mount-list-bindings.ts
|
|
1250
|
+
function anyRebuiltListIsGranular(segment, rebuilt) {
|
|
1251
|
+
if (!rebuilt.size) return false;
|
|
1252
|
+
const lists = collectLists(segment);
|
|
1253
|
+
for (const id of rebuilt) {
|
|
1254
|
+
if (lists.get(id)?.patches) return true;
|
|
1255
|
+
}
|
|
1256
|
+
return false;
|
|
1257
|
+
}
|
|
1258
|
+
function bindListsFromMarkers(rootEl, segment, bindings, inlinedItems, rebuiltLists, ownedItems) {
|
|
1259
|
+
const lists = collectLists(segment);
|
|
1260
|
+
if (lists.size === 0 && bindings.size === 0) return;
|
|
1261
|
+
const found = [];
|
|
1262
|
+
collectComments(rootEl, found, ownedItems);
|
|
1263
|
+
for (const marker of found) {
|
|
1264
|
+
if (!marker.data.startsWith(LIST_MARKER_PREFIX)) continue;
|
|
1265
|
+
const id = marker.data.slice(LIST_MARKER_PREFIX.length);
|
|
1266
|
+
const existing = bindings.get(id);
|
|
1267
|
+
if (existing) {
|
|
1268
|
+
if (existing.marker === marker && rootEl.contains(existing.marker))
|
|
1269
|
+
continue;
|
|
1270
|
+
for (const item of existing.items) {
|
|
1271
|
+
disposeRowBindings(item.bindingDisposers);
|
|
1272
|
+
if (rootEl.contains(item.node)) {
|
|
1273
|
+
item.node.parentElement?.removeChild(item.node);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
bindings.delete(id);
|
|
1277
|
+
rebuiltLists?.add(id);
|
|
1278
|
+
devHooks.listRebind?.(id, marker.parentElement);
|
|
1279
|
+
}
|
|
1280
|
+
const listSeg = lists.get(id);
|
|
1281
|
+
const liveParent = marker.parentElement;
|
|
1282
|
+
const items = [];
|
|
1283
|
+
if (inlinedItems) {
|
|
1284
|
+
let next = marker.nextElementSibling;
|
|
1285
|
+
for (let i = 0; i < listSeg.items.length && next !== null; i++) {
|
|
1286
|
+
validateInlinedRowMatch(listSeg.items[i].html, i, next, liveParent);
|
|
1287
|
+
items.push({
|
|
1288
|
+
ref: listSeg.items[i].ref,
|
|
1289
|
+
cacheKey: listSeg.items[i].cacheKey,
|
|
1290
|
+
html: listSeg.items[i].html,
|
|
1291
|
+
node: next,
|
|
1292
|
+
bindings: listSeg.items[i].bindings
|
|
1293
|
+
});
|
|
1294
|
+
next = next.nextElementSibling;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
const binding = { liveParent, items, marker };
|
|
1298
|
+
if (items.length > 0) {
|
|
1299
|
+
devHooks.missingRowKey?.(items[0].node, items[0].html, binding);
|
|
1300
|
+
}
|
|
1301
|
+
devHooks.eachInMorphSkip?.(id, liveParent, rootEl);
|
|
1302
|
+
bindings.set(id, binding);
|
|
1303
|
+
for (const bound of items) {
|
|
1304
|
+
if (bound.bindings?.length) {
|
|
1305
|
+
bound.bindingDisposers = wireRowBindings(bound.node, bound.bindings);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
function validateInlinedRowMatch(expectedHtml, index, boundEl, liveParent) {
|
|
1311
|
+
if (boundEl.outerHTML === expectedHtml) return;
|
|
1312
|
+
const { content, count } = parseRowTemplate(expectedHtml, liveParent);
|
|
1313
|
+
if (count !== 1) throw rowContractError(index, expectedHtml, liveParent);
|
|
1314
|
+
const expectedTag = content.firstElementChild.tagName;
|
|
1315
|
+
if (boundEl.tagName !== expectedTag)
|
|
1316
|
+
throw rowStructureError(index, boundEl.tagName, expectedTag);
|
|
1317
|
+
}
|
|
1318
|
+
function rowStructureError(index, gotTag, wantTag) {
|
|
1319
|
+
const got = gotTag.toLowerCase();
|
|
1320
|
+
const want = wantTag.toLowerCase();
|
|
1321
|
+
return new Error(
|
|
1322
|
+
`each(): row ${index} renders <${want}>, but the HTML parser wrapped the rows in <${got}> \u2014 so kerf cannot bind one row per element. This happens when an each() of <${want}> sits directly inside a table: the parser inserts <${got}> around the whole run. Put the each() inside an explicit <${got}> (e.g. <table><${got}>{each(...)}</${got}></table>) so the rows are the direct children kerf binds.`
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
function collectOwnedItems(bindings) {
|
|
1326
|
+
const owned = /* @__PURE__ */ new Set();
|
|
1327
|
+
for (const b of bindings.values()) {
|
|
1328
|
+
for (const item of b.items) owned.add(item.node);
|
|
1329
|
+
}
|
|
1330
|
+
return owned;
|
|
1331
|
+
}
|
|
1332
|
+
function cleanupOrphanBindings(segment, bindings, renderCtx) {
|
|
1333
|
+
const liveIds = collectLists(segment);
|
|
1334
|
+
for (const [id, binding] of bindings) {
|
|
1335
|
+
if (liveIds.has(id)) continue;
|
|
1336
|
+
for (const item of binding.items) {
|
|
1337
|
+
disposeRowBindings(item.bindingDisposers);
|
|
1338
|
+
item.node.remove();
|
|
1339
|
+
}
|
|
1340
|
+
binding.marker.remove();
|
|
1341
|
+
bindings.delete(id);
|
|
1342
|
+
renderCtx.bindingCounts.delete(id);
|
|
1343
|
+
renderCtx.bindingSources.delete(id);
|
|
1344
|
+
renderCtx.caches.delete(id);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
function collectComments(node, out, skip) {
|
|
1348
|
+
for (let c = node.firstChild; c; c = c.nextSibling) {
|
|
1349
|
+
if (c.nodeType === Node.COMMENT_NODE) out.push(c);
|
|
1350
|
+
else if (c.nodeType === Node.ELEMENT_NODE && !isOverlayHost(c) && !skip?.has(c))
|
|
1351
|
+
collectComments(c, out, skip);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
// src/static-subtree-morph.ts
|
|
1356
|
+
var START = 0;
|
|
1357
|
+
var OPEN_END = 1;
|
|
1358
|
+
var CLOSE = 2;
|
|
1359
|
+
var END = 3;
|
|
1360
|
+
var PARENT = 4;
|
|
1361
|
+
var INDEX = 5;
|
|
1362
|
+
var COUNT = 6;
|
|
1363
|
+
var FIRST = 7;
|
|
1364
|
+
var NEXT = 8;
|
|
1365
|
+
var FLAG = 9;
|
|
1366
|
+
var LAST = 10;
|
|
1367
|
+
var W = 11;
|
|
1368
|
+
var VOID = 1;
|
|
1369
|
+
var RAW = 2;
|
|
1370
|
+
var REFUSE = 4;
|
|
1371
|
+
var BOX = 8;
|
|
1372
|
+
var SENSITIVE = 16;
|
|
1373
|
+
var FOREIGN = 32;
|
|
1374
|
+
var FLAGS = /* @__PURE__ */ new Map();
|
|
1375
|
+
for (const [tags, bit] of [
|
|
1376
|
+
[
|
|
1377
|
+
"area base basefont bgsound br col embed frame hr img input keygen link meta param source track wbr",
|
|
1378
|
+
VOID
|
|
1379
|
+
],
|
|
1380
|
+
["script style textarea title xmp iframe noembed noframes", RAW],
|
|
1381
|
+
["html head body frameset image noscript plaintext", REFUSE],
|
|
1382
|
+
["table tbody thead tfoot tr colgroup", BOX],
|
|
1383
|
+
[
|
|
1384
|
+
"p li dd dt a button nobr select option optgroup datalist ruby rb rt rtc rp svg math template h1 h2 h3 h4 h5 h6 b big code em font i s small strike strong tt u",
|
|
1385
|
+
SENSITIVE
|
|
1386
|
+
],
|
|
1387
|
+
["svg math", FOREIGN]
|
|
1388
|
+
]) {
|
|
1389
|
+
for (const t of tags.split(" ")) FLAGS.set(t, (FLAGS.get(t) ?? 0) | bit);
|
|
1390
|
+
}
|
|
1391
|
+
var TABLE_PARENT = {
|
|
1392
|
+
tr: " tbody thead tfoot ",
|
|
1393
|
+
td: " tr ",
|
|
1394
|
+
th: " tr ",
|
|
1395
|
+
tbody: " table ",
|
|
1396
|
+
thead: " table ",
|
|
1397
|
+
tfoot: " table ",
|
|
1398
|
+
caption: " table ",
|
|
1399
|
+
colgroup: " table ",
|
|
1400
|
+
col: " colgroup "
|
|
1401
|
+
};
|
|
1402
|
+
var isSpace = (c) => c === 32 || c === 9 || c === 10 || c === 12 || c === 13;
|
|
1403
|
+
function scanStatic(html, rootTag) {
|
|
1404
|
+
const len = html.length;
|
|
1405
|
+
const tag = [rootTag];
|
|
1406
|
+
const r = [-1, 0, len, len, -1, 0, 0, -1, -1, FLAGS.get(rootTag) ?? 0, -1];
|
|
1407
|
+
const stack = [0];
|
|
1408
|
+
let textFrom = 0;
|
|
1409
|
+
let dq = -1;
|
|
1410
|
+
let sq = -1;
|
|
1411
|
+
const blankUntil = (to) => {
|
|
1412
|
+
for (let k = textFrom; k < to; k++)
|
|
1413
|
+
if (!isSpace(html.charCodeAt(k))) return false;
|
|
1414
|
+
return true;
|
|
1415
|
+
};
|
|
1416
|
+
for (let i = 0; (i = html.indexOf("<", i)) !== -1; ) {
|
|
1417
|
+
const top = stack[stack.length - 1];
|
|
1418
|
+
const topFlag = r[top * W + FLAG];
|
|
1419
|
+
const c = html.charCodeAt(i + 1);
|
|
1420
|
+
if (c !== 33 && c !== 47 && !((c | 32) >= 97 && (c | 32) <= 122)) {
|
|
1421
|
+
i++;
|
|
1422
|
+
continue;
|
|
1423
|
+
}
|
|
1424
|
+
if (topFlag & BOX && !blankUntil(i)) return null;
|
|
1425
|
+
if (c === 33) {
|
|
1426
|
+
const e2 = html.indexOf("-->", i + 4);
|
|
1427
|
+
if (!html.startsWith("!--", i + 1) || e2 < 0) return null;
|
|
1428
|
+
const body = html.slice(i + 4, e2);
|
|
1429
|
+
if (body[0] === ">" || body.startsWith("->") || body.includes("--!>"))
|
|
1430
|
+
return null;
|
|
1431
|
+
i = textFrom = e2 + 3;
|
|
1432
|
+
continue;
|
|
1433
|
+
}
|
|
1434
|
+
if (c === 47) {
|
|
1435
|
+
const gt = html.indexOf(">", i);
|
|
1436
|
+
if (top === 0 || gt < 0) return null;
|
|
1437
|
+
const t = tag[top];
|
|
1438
|
+
let j2 = i + 2 + t.length;
|
|
1439
|
+
if (!html.startsWith(t, i + 2)) {
|
|
1440
|
+
j2 = i + 2;
|
|
1441
|
+
while (j2 < gt && !isSpace(html.charCodeAt(j2))) j2++;
|
|
1442
|
+
if (html.slice(i + 2, j2).toLowerCase() !== t) return null;
|
|
1443
|
+
} else if (j2 !== gt && !isSpace(html.charCodeAt(j2))) return null;
|
|
1444
|
+
stack.pop();
|
|
1445
|
+
r[top * W + CLOSE] = i;
|
|
1446
|
+
i = textFrom = r[top * W + END] = gt + 1;
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
let j = i + 1;
|
|
1450
|
+
let ch;
|
|
1451
|
+
while (j < len && !isSpace(ch = html.charCodeAt(j)) && ch !== 47 && ch !== 62)
|
|
1452
|
+
j++;
|
|
1453
|
+
const name = html.slice(i + 1, j).toLowerCase();
|
|
1454
|
+
const flag = FLAGS.get(name) ?? 0;
|
|
1455
|
+
for (; ; ) {
|
|
1456
|
+
const gt = html.indexOf(">", j);
|
|
1457
|
+
if (gt < 0) return null;
|
|
1458
|
+
if (dq < j) dq = html.indexOf('"', j) >>> 0;
|
|
1459
|
+
if (sq < j) sq = html.indexOf("'", j) >>> 0;
|
|
1460
|
+
const qpos = dq < sq ? dq : sq;
|
|
1461
|
+
if (qpos > gt) {
|
|
1462
|
+
j = gt;
|
|
1463
|
+
break;
|
|
1464
|
+
}
|
|
1465
|
+
let k = qpos - 1;
|
|
1466
|
+
while (isSpace(html.charCodeAt(k))) k--;
|
|
1467
|
+
const close = html.indexOf(html[qpos], qpos + 1);
|
|
1468
|
+
if (html.charCodeAt(k) !== 61 || close < 0) return null;
|
|
1469
|
+
j = close + 1;
|
|
1470
|
+
}
|
|
1471
|
+
const want = TABLE_PARENT[name];
|
|
1472
|
+
if (flag & REFUSE || (want !== void 0 ? !want.includes(` ${tag[top]} `) : topFlag & BOX))
|
|
1473
|
+
return null;
|
|
1474
|
+
const e = tag.length;
|
|
1475
|
+
const p = top * W;
|
|
1476
|
+
const last = r[p + LAST];
|
|
1477
|
+
if (last < 0) r[p + FIRST] = e;
|
|
1478
|
+
else r[last * W + NEXT] = e;
|
|
1479
|
+
r[p + LAST] = e;
|
|
1480
|
+
tag.push(name);
|
|
1481
|
+
r.push(i, j + 1, j + 1, j + 1, top, r[p + COUNT]++, 0, -1, -1, flag, -1);
|
|
1482
|
+
i = textFrom = j + 1;
|
|
1483
|
+
if (flag & (FOREIGN | RAW)) {
|
|
1484
|
+
const re = new RegExp(`<(/?)${name}[\\s/>]`, "gi");
|
|
1485
|
+
re.lastIndex = i;
|
|
1486
|
+
let depth = flag & FOREIGN && html[j - 1] === "/" ? 0 : 1;
|
|
1487
|
+
while (depth > 0) {
|
|
1488
|
+
const m = re.exec(html);
|
|
1489
|
+
if (m === null) return null;
|
|
1490
|
+
const gt = html.indexOf(">", m.index);
|
|
1491
|
+
if (m[1] === "/") depth--;
|
|
1492
|
+
else if (flag & FOREIGN && html[gt - 1] !== "/") depth++;
|
|
1493
|
+
r[e * W + CLOSE] = m.index;
|
|
1494
|
+
i = textFrom = r[e * W + END] = gt + 1;
|
|
1495
|
+
}
|
|
1496
|
+
} else if (!(flag & VOID)) {
|
|
1497
|
+
stack.push(e);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
return stack.length > 1 || r[FLAG] & BOX && !blankUntil(len) ? null : { tag, r };
|
|
1501
|
+
}
|
|
1502
|
+
function commonRun(a, b, max, fromEnd) {
|
|
1503
|
+
const at = (s, from, to) => fromEnd ? s.slice(s.length - to, s.length - from) : s.slice(from, to);
|
|
1504
|
+
let n = 0;
|
|
1505
|
+
for (let step = 1024; n < max; ) {
|
|
1506
|
+
const to = Math.min(n + step, max);
|
|
1507
|
+
if (at(a, n, to) === at(b, n, to)) {
|
|
1508
|
+
n = to;
|
|
1509
|
+
step *= 2;
|
|
1510
|
+
} else if (step > 16) step >>= 2;
|
|
1511
|
+
else break;
|
|
1512
|
+
}
|
|
1513
|
+
while (n < max && at(a, n, n + 1) === at(b, n, n + 1)) n++;
|
|
1514
|
+
return n;
|
|
1515
|
+
}
|
|
1516
|
+
function overlapping(s, host, p, to) {
|
|
1517
|
+
const out = [];
|
|
1518
|
+
for (let c = s.r[host * W + FIRST]; c >= 0; c = s.r[c * W + NEXT])
|
|
1519
|
+
if (s.r[c * W + END] > p && s.r[c * W + START] < to) out.push(c);
|
|
1520
|
+
return out;
|
|
1521
|
+
}
|
|
1522
|
+
function morphStaticChange(rootEl, prev, next, cache, ownedItems) {
|
|
1523
|
+
const rootTag = rootEl.localName;
|
|
1524
|
+
const sa = cache.html === prev ? cache.scan : scanStatic(prev, rootTag);
|
|
1525
|
+
const sb = scanStatic(next, rootTag);
|
|
1526
|
+
cache.html = next;
|
|
1527
|
+
cache.scan = sb;
|
|
1528
|
+
if (sa === null || sb === null) return false;
|
|
1529
|
+
const a = sa.r;
|
|
1530
|
+
const b = sb.r;
|
|
1531
|
+
const delta = next.length - prev.length;
|
|
1532
|
+
const p = commonRun(prev, next, Math.min(prev.length, next.length), false);
|
|
1533
|
+
const q = commonRun(prev, next, Math.min(prev.length, next.length) - p, true);
|
|
1534
|
+
const aEnd = prev.length - q;
|
|
1535
|
+
let host = 0;
|
|
1536
|
+
for (let lo = 1, hi = sa.tag.length - 1; lo <= hi; ) {
|
|
1537
|
+
const mid = lo + hi >> 1;
|
|
1538
|
+
if (a[mid * W + START] < p) {
|
|
1539
|
+
host = mid;
|
|
1540
|
+
lo = mid + 1;
|
|
1541
|
+
} else hi = mid - 1;
|
|
1542
|
+
}
|
|
1543
|
+
while (!(a[host * W + OPEN_END] <= p && a[host * W + CLOSE] >= aEnd))
|
|
1544
|
+
host = a[host * W + PARENT];
|
|
1545
|
+
for (let x = host; x > 0; x = a[x * W + PARENT])
|
|
1546
|
+
if (a[x * W + FLAG] & SENSITIVE) host = a[x * W + PARENT];
|
|
1547
|
+
let olds;
|
|
1548
|
+
let news;
|
|
1549
|
+
for (; ; host = a[host * W + PARENT]) {
|
|
1550
|
+
if (host < 0) return false;
|
|
1551
|
+
if (b[host * W + CLOSE] - delta !== a[host * W + CLOSE]) continue;
|
|
1552
|
+
olds = overlapping(sa, host, p, aEnd);
|
|
1553
|
+
news = overlapping(sb, host, p, next.length - q);
|
|
1554
|
+
const k = olds.length;
|
|
1555
|
+
let ok = k > 0 && k === news.length && a[olds[0] * W + START] <= p && b[news[0] * W + START] <= p && a[olds[k - 1] * W + END] >= aEnd && b[news[k - 1] * W + END] - delta === a[olds[k - 1] * W + END];
|
|
1556
|
+
for (let m = 0; ok && m < k; m++) {
|
|
1557
|
+
ok = sa.tag[olds[m]] === sb.tag[news[m]] && (m === 0 || prev.slice(a[olds[m - 1] * W + END], a[olds[m] * W + START]) === next.slice(b[news[m - 1] * W + END], b[news[m] * W + START]));
|
|
1558
|
+
}
|
|
1559
|
+
if (ok) break;
|
|
1560
|
+
}
|
|
1561
|
+
if (rootEl.childElementCount !== a[COUNT]) return false;
|
|
1562
|
+
const path = [];
|
|
1563
|
+
for (let x = host; x > 0; x = a[x * W + PARENT]) path.push(x);
|
|
1564
|
+
let live = rootEl;
|
|
1565
|
+
for (let m = path.length - 1; m >= 0; m--) {
|
|
1566
|
+
const x = path[m];
|
|
1567
|
+
const el = live.children[a[x * W + INDEX]];
|
|
1568
|
+
if (el.localName !== sa.tag[x] || el.childElementCount !== a[x * W + COUNT] || el.dataset.morphSkip !== void 0 || el.dataset.morphSkipChildren !== void 0 || el === document.activeElement)
|
|
1569
|
+
return false;
|
|
1570
|
+
live = el;
|
|
1571
|
+
}
|
|
1572
|
+
const lives = [];
|
|
1573
|
+
let html = "";
|
|
1574
|
+
for (let m = 0; m < olds.length; m++) {
|
|
1575
|
+
const o = olds[m] * W;
|
|
1576
|
+
const n = news[m] * W;
|
|
1577
|
+
const nextChild = next.slice(b[n + START], b[n + END]);
|
|
1578
|
+
if (prev.slice(a[o + START], a[o + END]) === nextChild) continue;
|
|
1579
|
+
const el = live.children[a[o + INDEX]];
|
|
1580
|
+
if (el.localName !== sa.tag[olds[m]]) return false;
|
|
1581
|
+
lives.push(el);
|
|
1582
|
+
html += nextChild;
|
|
1583
|
+
}
|
|
1584
|
+
const tpl = live.cloneNode(false);
|
|
1585
|
+
tpl.innerHTML = html;
|
|
1586
|
+
const tos = tpl.childNodes;
|
|
1587
|
+
if (tos.length !== lives.length) return false;
|
|
1588
|
+
for (let m = 0; m < lives.length; m++) {
|
|
1589
|
+
const from = lives[m];
|
|
1590
|
+
const to = tos[m];
|
|
1591
|
+
if (to.localName !== from.localName || keyOf(from) !== keyOf(to) || keyOf(from) === "" && protectionOf(from) !== protectionOf(to))
|
|
1592
|
+
return false;
|
|
1593
|
+
}
|
|
1594
|
+
const focusSnap = captureFocus(live);
|
|
1595
|
+
for (let m = 0; m < lives.length; m++)
|
|
1596
|
+
_morphElement(lives[m], tos[m], ownedItems);
|
|
1597
|
+
if (focusSnap !== null) restoreFocus(focusSnap);
|
|
1598
|
+
return true;
|
|
1599
|
+
}
|
|
1600
|
+
function keyOf(el) {
|
|
1601
|
+
return el.id !== "" ? `#${el.id}` : el.dataset.key !== void 0 ? `k${el.dataset.key}` : "";
|
|
1602
|
+
}
|
|
1603
|
+
function protectionOf(el) {
|
|
1604
|
+
const d = el.dataset;
|
|
1605
|
+
return `${d.morphSkip !== void 0}${d.morphSkipChildren !== void 0}${d.morphPreserve !== void 0}`;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1133
1608
|
// src/mount.ts
|
|
1134
1609
|
var MOUNTED_MARKER = /* @__PURE__ */ Symbol.for("kerfjs.mounted");
|
|
1135
1610
|
var NESTED_MOUNT_MSG = "mount: rootEl is already inside (or contains) a mounted tree. kerf supports one mount per tree \u2014 compose with plain functions that return JSX instead of nesting mounts.";
|
|
@@ -1155,15 +1630,17 @@ function assertNotInsideMountedTree(rootEl) {
|
|
|
1155
1630
|
);
|
|
1156
1631
|
}
|
|
1157
1632
|
let ancestor = rootEl.parentElement;
|
|
1158
|
-
while (ancestor) {
|
|
1633
|
+
while (ancestor && !isOverlayHost(ancestor)) {
|
|
1159
1634
|
if (isMounted(ancestor)) throw new Error(NESTED_MOUNT_MSG);
|
|
1160
1635
|
ancestor = ancestor.parentElement;
|
|
1161
1636
|
}
|
|
1162
1637
|
const stack = [];
|
|
1163
|
-
for (let i = 0; i < rootEl.children.length; i++)
|
|
1638
|
+
for (let i = 0; i < rootEl.children.length; i++)
|
|
1639
|
+
stack.push(rootEl.children[i]);
|
|
1164
1640
|
while (stack.length > 0) {
|
|
1165
1641
|
const cur = stack.pop();
|
|
1166
1642
|
if (isMounted(cur)) throw new Error(NESTED_MOUNT_MSG);
|
|
1643
|
+
if (isOverlayHost(cur)) continue;
|
|
1167
1644
|
for (let i = 0; i < cur.children.length; i++) stack.push(cur.children[i]);
|
|
1168
1645
|
}
|
|
1169
1646
|
}
|
|
@@ -1196,7 +1673,9 @@ function mount(rootEl, render) {
|
|
|
1196
1673
|
let prevWiredBindings = [];
|
|
1197
1674
|
let isFirst = true;
|
|
1198
1675
|
let prevStaticHtml = "";
|
|
1676
|
+
const scanCache = { html: "", scan: null };
|
|
1199
1677
|
const valueOnlyWarnCtx = { warned: false };
|
|
1678
|
+
const boundRows = () => bindingCtx.list.length > 0 && bindings.size > 0 ? collectOwnedItems(bindings) : void 0;
|
|
1200
1679
|
const runRenderPass = () => {
|
|
1201
1680
|
renderCtx.counter = 0;
|
|
1202
1681
|
renderCtx.keysThisRender.clear();
|
|
@@ -1228,7 +1707,12 @@ function mount(rootEl, render) {
|
|
|
1228
1707
|
runFirstRender(rootEl, segment, bindings);
|
|
1229
1708
|
prevStaticHtml = flattenWithoutListItems(segment);
|
|
1230
1709
|
devHooks.parserRepair?.(prevStaticHtml);
|
|
1231
|
-
bindingDisposers = wireBindings(
|
|
1710
|
+
bindingDisposers = wireBindings(
|
|
1711
|
+
rootEl,
|
|
1712
|
+
bindingCtx,
|
|
1713
|
+
bindingDisposers,
|
|
1714
|
+
boundRows()
|
|
1715
|
+
);
|
|
1232
1716
|
if (devHooks.staleBindingEnabled?.()) prevWiredBindings = bindingCtx.list;
|
|
1233
1717
|
isFirst = false;
|
|
1234
1718
|
} else {
|
|
@@ -1238,10 +1722,12 @@ function mount(rootEl, render) {
|
|
|
1238
1722
|
bindings,
|
|
1239
1723
|
renderCtx,
|
|
1240
1724
|
prevStaticHtml,
|
|
1241
|
-
valueOnlyWarnCtx
|
|
1725
|
+
valueOnlyWarnCtx,
|
|
1726
|
+
scanCache
|
|
1242
1727
|
);
|
|
1243
1728
|
if (anyRebuiltListIsGranular(segment, renderCtx.rebuiltLists)) {
|
|
1244
|
-
for (const id of renderCtx.rebuiltLists)
|
|
1729
|
+
for (const id of renderCtx.rebuiltLists)
|
|
1730
|
+
renderCtx.bindingCounts.delete(id);
|
|
1245
1731
|
result = runRenderPass();
|
|
1246
1732
|
segment = resultToSegment(result);
|
|
1247
1733
|
nextStaticHtml = runSubsequentRender(
|
|
@@ -1250,12 +1736,19 @@ function mount(rootEl, render) {
|
|
|
1250
1736
|
bindings,
|
|
1251
1737
|
renderCtx,
|
|
1252
1738
|
prevStaticHtml,
|
|
1253
|
-
valueOnlyWarnCtx
|
|
1739
|
+
valueOnlyWarnCtx,
|
|
1740
|
+
scanCache
|
|
1254
1741
|
);
|
|
1255
1742
|
}
|
|
1256
1743
|
if (nextStaticHtml !== prevStaticHtml) {
|
|
1257
|
-
bindingDisposers = wireBindings(
|
|
1258
|
-
|
|
1744
|
+
bindingDisposers = wireBindings(
|
|
1745
|
+
rootEl,
|
|
1746
|
+
bindingCtx,
|
|
1747
|
+
bindingDisposers,
|
|
1748
|
+
boundRows()
|
|
1749
|
+
);
|
|
1750
|
+
if (devHooks.staleBindingEnabled?.())
|
|
1751
|
+
prevWiredBindings = bindingCtx.list;
|
|
1259
1752
|
} else {
|
|
1260
1753
|
devHooks.staleBinding?.(prevWiredBindings, bindingCtx.list);
|
|
1261
1754
|
}
|
|
@@ -1283,11 +1776,7 @@ function mount(rootEl, render) {
|
|
|
1283
1776
|
renderCtx.previousCallCount = renderCtx.counter;
|
|
1284
1777
|
devHooks.listInvariants?.(rootEl, bindings, expectedCounts || void 0);
|
|
1285
1778
|
}
|
|
1286
|
-
const
|
|
1287
|
-
reconcileAndCommitListPhase(renderStaticPhase());
|
|
1288
|
-
});
|
|
1289
|
-
return () => {
|
|
1290
|
-
disposeEffect();
|
|
1779
|
+
const releaseResources = () => {
|
|
1291
1780
|
for (const d of bindingDisposers) d();
|
|
1292
1781
|
bindingDisposers = [];
|
|
1293
1782
|
for (const b of bindings.values()) {
|
|
@@ -1296,23 +1785,68 @@ function mount(rootEl, render) {
|
|
|
1296
1785
|
listenerWarnObserver?.disconnect();
|
|
1297
1786
|
setMounted(rootEl, false);
|
|
1298
1787
|
};
|
|
1788
|
+
const priorChildren = rootEl.firstChild ? Array.from(rootEl.childNodes) : [];
|
|
1789
|
+
let disposeEffect;
|
|
1790
|
+
try {
|
|
1791
|
+
disposeEffect = effect(() => {
|
|
1792
|
+
reconcileAndCommitListPhase(renderStaticPhase());
|
|
1793
|
+
});
|
|
1794
|
+
} catch (err) {
|
|
1795
|
+
releaseResources();
|
|
1796
|
+
rootEl.replaceChildren(...priorChildren);
|
|
1797
|
+
throw err;
|
|
1798
|
+
}
|
|
1799
|
+
return () => {
|
|
1800
|
+
disposeEffect();
|
|
1801
|
+
releaseResources();
|
|
1802
|
+
};
|
|
1299
1803
|
}
|
|
1300
1804
|
function runFirstRender(rootEl, segment, bindings) {
|
|
1301
|
-
|
|
1805
|
+
const html = flatten(segment, true);
|
|
1806
|
+
if (hasCustomTag(html)) {
|
|
1807
|
+
const tpl = rootEl.cloneNode(false);
|
|
1808
|
+
tpl.innerHTML = html;
|
|
1809
|
+
const content = document.createDocumentFragment();
|
|
1810
|
+
while (tpl.firstChild !== null) content.appendChild(tpl.firstChild);
|
|
1811
|
+
seedRenderedAttrs(content);
|
|
1812
|
+
rootEl.replaceChildren(content);
|
|
1813
|
+
} else {
|
|
1814
|
+
rootEl.innerHTML = html;
|
|
1815
|
+
}
|
|
1302
1816
|
bindListsFromMarkers(rootEl, segment, bindings, true);
|
|
1303
1817
|
}
|
|
1304
|
-
function runSubsequentRender(rootEl, segment, bindings, renderCtx, prevStaticHtml, valueOnlyWarnCtx) {
|
|
1818
|
+
function runSubsequentRender(rootEl, segment, bindings, renderCtx, prevStaticHtml, valueOnlyWarnCtx, scanCache) {
|
|
1305
1819
|
renderCtx.rebuiltLists.clear();
|
|
1306
1820
|
const currentStaticHtml = flattenWithoutListItems(segment);
|
|
1307
1821
|
if (currentStaticHtml === prevStaticHtml) {
|
|
1308
1822
|
return prevStaticHtml;
|
|
1309
1823
|
}
|
|
1310
|
-
devHooks.valueOnlyRerender?.(
|
|
1824
|
+
devHooks.valueOnlyRerender?.(
|
|
1825
|
+
prevStaticHtml,
|
|
1826
|
+
currentStaticHtml,
|
|
1827
|
+
valueOnlyWarnCtx
|
|
1828
|
+
);
|
|
1311
1829
|
cleanupOrphanBindings(segment, bindings, renderCtx);
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1830
|
+
const ownedItems = collectOwnedItems(bindings);
|
|
1831
|
+
if (!morphStaticChange(
|
|
1832
|
+
rootEl,
|
|
1833
|
+
prevStaticHtml,
|
|
1834
|
+
currentStaticHtml,
|
|
1835
|
+
scanCache,
|
|
1836
|
+
ownedItems
|
|
1837
|
+
)) {
|
|
1838
|
+
const template = rootEl.cloneNode(false);
|
|
1839
|
+
template.innerHTML = currentStaticHtml;
|
|
1840
|
+
morph(rootEl, template, ownedItems);
|
|
1841
|
+
}
|
|
1842
|
+
bindListsFromMarkers(
|
|
1843
|
+
rootEl,
|
|
1844
|
+
segment,
|
|
1845
|
+
bindings,
|
|
1846
|
+
false,
|
|
1847
|
+
renderCtx.rebuiltLists,
|
|
1848
|
+
ownedItems
|
|
1849
|
+
);
|
|
1316
1850
|
return currentStaticHtml;
|
|
1317
1851
|
}
|
|
1318
1852
|
function coerceRenderResult(result) {
|
|
@@ -1322,107 +1856,7 @@ function coerceRenderResult(result) {
|
|
|
1322
1856
|
function resultToSegment(result) {
|
|
1323
1857
|
return isSafeHtml(result) ? result.__segment ?? { kind: "static", html: result.__html } : { kind: "static", html: coerceRenderResult(result) };
|
|
1324
1858
|
}
|
|
1325
|
-
function anyRebuiltListIsGranular(segment, rebuilt) {
|
|
1326
|
-
if (!rebuilt.size) return false;
|
|
1327
|
-
const lists = collectLists(segment);
|
|
1328
|
-
for (const id of rebuilt) {
|
|
1329
|
-
if (lists.get(id)?.patches) return true;
|
|
1330
|
-
}
|
|
1331
|
-
return false;
|
|
1332
|
-
}
|
|
1333
|
-
function bindListsFromMarkers(rootEl, segment, bindings, inlinedItems, rebuiltLists) {
|
|
1334
|
-
const lists = collectLists(segment);
|
|
1335
|
-
const found = [];
|
|
1336
|
-
collectComments(rootEl, found);
|
|
1337
|
-
for (const marker of found) {
|
|
1338
|
-
if (!marker.data.startsWith(LIST_MARKER_PREFIX)) continue;
|
|
1339
|
-
const id = marker.data.slice(LIST_MARKER_PREFIX.length);
|
|
1340
|
-
const existing = bindings.get(id);
|
|
1341
|
-
if (existing) {
|
|
1342
|
-
if (existing.marker === marker && rootEl.contains(existing.marker)) continue;
|
|
1343
|
-
for (const item of existing.items) {
|
|
1344
|
-
disposeRowBindings(item.bindingDisposers);
|
|
1345
|
-
if (rootEl.contains(item.node)) {
|
|
1346
|
-
item.node.parentElement?.removeChild(item.node);
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
bindings.delete(id);
|
|
1350
|
-
rebuiltLists?.add(id);
|
|
1351
|
-
devHooks.listRebind?.(id, marker.parentElement);
|
|
1352
|
-
}
|
|
1353
|
-
const listSeg = lists.get(id);
|
|
1354
|
-
const liveParent = marker.parentElement;
|
|
1355
|
-
const items = [];
|
|
1356
|
-
if (inlinedItems) {
|
|
1357
|
-
let next = marker.nextElementSibling;
|
|
1358
|
-
for (let i = 0; i < listSeg.items.length && next !== null; i++) {
|
|
1359
|
-
validateInlinedRowMatch(listSeg.items[i].html, i, next, liveParent);
|
|
1360
|
-
const rowBindings = listSeg.items[i].bindings;
|
|
1361
|
-
const bound = {
|
|
1362
|
-
ref: listSeg.items[i].ref,
|
|
1363
|
-
cacheKey: listSeg.items[i].cacheKey,
|
|
1364
|
-
html: listSeg.items[i].html,
|
|
1365
|
-
node: next,
|
|
1366
|
-
bindings: rowBindings
|
|
1367
|
-
};
|
|
1368
|
-
if (rowBindings?.length) {
|
|
1369
|
-
bound.bindingDisposers = wireRowBindings(next, rowBindings);
|
|
1370
|
-
}
|
|
1371
|
-
items.push(bound);
|
|
1372
|
-
next = next.nextElementSibling;
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
const binding = { liveParent, items, marker };
|
|
1376
|
-
if (items.length > 0) {
|
|
1377
|
-
devHooks.missingRowKey?.(items[0].node, items[0].html, binding);
|
|
1378
|
-
}
|
|
1379
|
-
devHooks.eachInMorphSkip?.(id, liveParent, rootEl);
|
|
1380
|
-
bindings.set(id, binding);
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
function validateInlinedRowMatch(expectedHtml, index, boundEl, liveParent) {
|
|
1384
|
-
if (boundEl.outerHTML === expectedHtml) return;
|
|
1385
|
-
const { content, count } = parseRowTemplate(expectedHtml, liveParent);
|
|
1386
|
-
if (count !== 1) throw rowContractError(index, expectedHtml, liveParent);
|
|
1387
|
-
const expectedTag = content.firstElementChild.tagName;
|
|
1388
|
-
if (boundEl.tagName !== expectedTag) throw rowStructureError(index, boundEl.tagName, expectedTag);
|
|
1389
|
-
}
|
|
1390
|
-
function rowStructureError(index, gotTag, wantTag) {
|
|
1391
|
-
const got = gotTag.toLowerCase();
|
|
1392
|
-
const want = wantTag.toLowerCase();
|
|
1393
|
-
return new Error(
|
|
1394
|
-
`each(): row ${index} renders <${want}>, but the HTML parser wrapped the rows in <${got}> \u2014 so kerf cannot bind one row per element. This happens when an each() of <${want}> sits directly inside a table: the parser inserts <${got}> around the whole run. Put the each() inside an explicit <${got}> (e.g. <table><${got}>{each(...)}</${got}></table>) so the rows are the direct children kerf binds.`
|
|
1395
|
-
);
|
|
1396
|
-
}
|
|
1397
|
-
function collectOwnedItems(bindings) {
|
|
1398
|
-
const owned = /* @__PURE__ */ new Set();
|
|
1399
|
-
for (const b of bindings.values()) {
|
|
1400
|
-
for (const item of b.items) owned.add(item.node);
|
|
1401
|
-
}
|
|
1402
|
-
return owned;
|
|
1403
|
-
}
|
|
1404
|
-
function cleanupOrphanBindings(segment, bindings, renderCtx) {
|
|
1405
|
-
const liveIds = collectLists(segment);
|
|
1406
|
-
for (const [id, binding] of bindings) {
|
|
1407
|
-
if (liveIds.has(id)) continue;
|
|
1408
|
-
for (const item of binding.items) {
|
|
1409
|
-
disposeRowBindings(item.bindingDisposers);
|
|
1410
|
-
item.node.remove();
|
|
1411
|
-
}
|
|
1412
|
-
binding.marker.remove();
|
|
1413
|
-
bindings.delete(id);
|
|
1414
|
-
renderCtx.bindingCounts.delete(id);
|
|
1415
|
-
renderCtx.bindingSources.delete(id);
|
|
1416
|
-
renderCtx.caches.delete(id);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
function collectComments(node, out) {
|
|
1420
|
-
for (let c = node.firstChild; c; c = c.nextSibling) {
|
|
1421
|
-
if (c.nodeType === Node.COMMENT_NODE) out.push(c);
|
|
1422
|
-
else if (c.nodeType === Node.ELEMENT_NODE) collectComments(c, out);
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
1859
|
|
|
1426
1860
|
export { captureFocus, each, morph, mount, moveNode, restoreFocus };
|
|
1427
1861
|
|
|
1428
|
-
//# sourceMappingURL=chunk-
|
|
1862
|
+
//# sourceMappingURL=chunk-YVBK73GU.js.map
|