test(runtime-core): add test case for createBlock with disableTracking (#1169)

This commit is contained in:
underfin 2020-05-18 22:20:05 +08:00 committed by GitHub
parent efa3214866
commit 520cad7d4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -405,6 +405,39 @@ describe('vnode', () => {
})) }))
expect(vnode.dynamicChildren).toStrictEqual([vnode1]) expect(vnode.dynamicChildren).toStrictEqual([vnode1])
}) })
test('openBlock w/ disableTracking: true', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
// a v-for fragment block generated by the compiler
// disables tracking because it always diffs its
// children.
(vnode1 = (openBlock(true),
createBlock(Fragment, null, [
hoist,
/*vnode2*/ createVNode(() => {}, null, 'text')
])))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
expect(vnode1.dynamicChildren).toStrictEqual([])
})
test('openBlock without disableTracking: true', () => {
const hoist = createVNode('div')
let vnode1, vnode2
const vnode = (openBlock(),
createBlock('div', null, [
(vnode1 = (openBlock(),
createBlock(Fragment, null, [
hoist,
(vnode2 = createVNode(() => {}, null, 'text'))
])))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
expect(vnode1.dynamicChildren).toStrictEqual([vnode2])
})
}) })
describe('transformVNodeArgs', () => { describe('transformVNodeArgs', () => {