|
@@ -1791,23 +1791,45 @@ describe('Vapor Mode hydration', () => {
|
|
|
|
|
|
|
|
describe('for', () => {
|
|
describe('for', () => {
|
|
|
test('basic v-for', async () => {
|
|
test('basic v-for', async () => {
|
|
|
|
|
+ const { container, data } = await testHydration(
|
|
|
|
|
+ `<template>
|
|
|
|
|
+ <span v-for="item in data" :key="item">{{ item }}</span>
|
|
|
|
|
+ </template>`,
|
|
|
|
|
+ undefined,
|
|
|
|
|
+ ref(['a', 'b', 'c']),
|
|
|
|
|
+ )
|
|
|
|
|
+ expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
|
|
|
|
|
+ `"<span>a</span><span>b</span><span>c</span><!--for-->"`,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ data.value.push('d')
|
|
|
|
|
+ await nextTick()
|
|
|
|
|
+ expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
|
|
|
|
|
+ `"<span>a</span><span>b</span><span>c</span><span>d</span><!--for-->"`,
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ test('v-for with insertion parent + sibling component', async () => {
|
|
|
const { container, data } = await testHydration(
|
|
const { container, data } = await testHydration(
|
|
|
`<template>
|
|
`<template>
|
|
|
<div>
|
|
<div>
|
|
|
<span v-for="item in data" :key="item">{{ item }}</span>
|
|
<span v-for="item in data" :key="item">{{ item }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ <components.Child/>
|
|
|
</template>`,
|
|
</template>`,
|
|
|
- undefined,
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ Child: `<template><div>{{data.length}}</div></template>`,
|
|
|
|
|
+ },
|
|
|
ref(['a', 'b', 'c']),
|
|
ref(['a', 'b', 'c']),
|
|
|
)
|
|
)
|
|
|
expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
|
|
expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
|
|
|
- `"<div><span>a</span><span>b</span><span>c</span><!--for--></div>"`,
|
|
|
|
|
|
|
+ `"<div><span>a</span><span>b</span><span>c</span><!--for--></div><div>3</div>"`,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
data.value.push('d')
|
|
data.value.push('d')
|
|
|
await nextTick()
|
|
await nextTick()
|
|
|
expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
|
|
expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
|
|
|
- `"<div><span>a</span><span>b</span><span>c</span><span>d</span><!--for--></div>"`,
|
|
|
|
|
|
|
+ `"<div><span>a</span><span>b</span><span>c</span><span>d</span><!--for--></div><div>4</div>"`,
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
|