@@ -1,4 +1,4 @@
|
||||
import { createApp, ref, nextTick } from '../src'
|
||||
import { createApp, ref, nextTick, reactive } from '../src'
|
||||
|
||||
describe('compiler + runtime integration', () => {
|
||||
it('should support runtime template compilation', () => {
|
||||
@@ -247,4 +247,38 @@ describe('compiler + runtime integration', () => {
|
||||
|
||||
document.querySelector = origin
|
||||
})
|
||||
|
||||
test('v-if + v-once', async () => {
|
||||
const ok = ref(true)
|
||||
const App = {
|
||||
setup() {
|
||||
return { ok }
|
||||
},
|
||||
template: `<div>{{ ok }}<div v-if="ok" v-once>{{ ok }}</div></div>`
|
||||
}
|
||||
const container = document.createElement('div')
|
||||
createApp(App).mount(container)
|
||||
|
||||
expect(container.innerHTML).toBe(`<div>true<div>true</div></div>`)
|
||||
ok.value = false
|
||||
await nextTick()
|
||||
expect(container.innerHTML).toBe(`<div>false<div>true</div></div>`)
|
||||
})
|
||||
|
||||
test('v-for + v-once', async () => {
|
||||
const list = reactive([1])
|
||||
const App = {
|
||||
setup() {
|
||||
return { list }
|
||||
},
|
||||
template: `<div>{{ list.length }}<div v-for="i in list" v-once>{{ i }}</div></div>`
|
||||
}
|
||||
const container = document.createElement('div')
|
||||
createApp(App).mount(container)
|
||||
|
||||
expect(container.innerHTML).toBe(`<div>1<div>1</div></div>`)
|
||||
list.push(2)
|
||||
await nextTick()
|
||||
expect(container.innerHTML).toBe(`<div>2<div>1</div></div>`)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user