Skip to content

Commit 5a77532

Browse files
committed
fix(runtime-vapor): fix vFor bugs
1 parent f70f9d1 commit 5a77532

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/runtime-vapor/__tests__/for.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ describe('createFor', () => {
778778
)
779779
})
780780

781-
test.todo('prepend', async () => {
781+
test('prepend', async () => {
782782
const arr = ref<number[]>([4, 5])
783783
const { host, html } = render(arr)
784784
expect(host.children.length).toBe(2)

packages/runtime-vapor/src/apiCreateFor.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,15 @@ export const createFor = (
196196
endOffset++
197197
continue
198198
}
199-
if (endOffset !== 0) {
200-
anchorFallback = normalizeAnchor(newBlocks[currentIndex + 1].nodes)
201-
}
202199
break
203200
}
204201

202+
if (endOffset !== 0) {
203+
anchorFallback = normalizeAnchor(
204+
newBlocks[newLength - endOffset].nodes,
205+
)
206+
}
207+
205208
while (startOffset < sharedBlockCount - endOffset) {
206209
const currentItem = getItem(source, startOffset)
207210
const currentKey = getKey(...currentItem)

0 commit comments

Comments
 (0)