Skip to content

Commit 37b552f

Browse files
committed
Fix hydration LIS computation lookup range
1 parent 8f35b0e commit 37b552f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/runtime/internal/dom.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type NodeEx = Node & {
2020
};
2121

2222
function upper_bound(low: number, high: number, key: (index: number) => number, value: number) {
23-
// Return first index of value larger than input value
23+
// Return first index of value larger than input value in the range [low, high)
2424
while (low < high) {
2525
const mid = low + ((high - low) >> 1);
2626
if (key(mid) <= value) {
@@ -69,7 +69,7 @@ function init_hydrate(target: NodeEx) {
6969
// Find the largest subsequence length such that it ends in a value less than our current value
7070

7171
// upper_bound returns first greater value, so we subtract one
72-
const seqLen = upper_bound(1, 0, idx => children[m[idx]].claim_order, current) - 1;
72+
const seqLen = upper_bound(1, longest + 1, idx => children[m[idx]].claim_order, current) - 1;
7373

7474
p[i] = m[seqLen] + 1;
7575

@@ -366,7 +366,7 @@ export function claim_text(nodes: ChildNodeArray, data) {
366366
return claim_node<Text>(
367367
nodes,
368368
(node: ChildNode): node is Text => node.nodeType === 3,
369-
(node: Text) => node.data = '' + data,
369+
(node: Text) => { node.data = '' + data },
370370
() => text(data),
371371
true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements
372372
);

0 commit comments

Comments
 (0)