fix: Suspense should include into dynamic children (#653)

fix #649
This commit is contained in:
likui 2020-01-22 23:45:27 +08:00 committed by Evan You
parent 2569890e31
commit ec63623fe8
2 changed files with 35 additions and 1 deletions

View File

@ -232,7 +232,7 @@ describe('vnode', () => {
}) })
describe('dynamic children', () => { describe('dynamic children', () => {
test('single call openBlock', () => { test('with patchFlags', () => {
const hoist = createVNode('div') const hoist = createVNode('div')
let vnode1 let vnode1
const vnode = (openBlock(), const vnode = (openBlock(),
@ -259,5 +259,38 @@ describe('vnode', () => {
expect(vnode.dynamicChildren).toStrictEqual([vnode1, vnode2]) expect(vnode.dynamicChildren).toStrictEqual([vnode1, vnode2])
expect(vnode2.dynamicChildren).toStrictEqual([vnode3]) expect(vnode2.dynamicChildren).toStrictEqual([vnode3])
}) })
test('with stateful component', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode({}, null, 'text'))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
})
test('with functional component', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode(() => {}, null, 'text'))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
})
test('with suspense', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode(() => {}, null, 'text'))
]))
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
})
}) })
}) })

View File

@ -274,6 +274,7 @@ export function createVNode(
shouldTrack > 0 && shouldTrack > 0 &&
currentBlock !== null && currentBlock !== null &&
(patchFlag > 0 || (patchFlag > 0 ||
shapeFlag & ShapeFlags.SUSPENSE ||
shapeFlag & ShapeFlags.STATEFUL_COMPONENT || shapeFlag & ShapeFlags.STATEFUL_COMPONENT ||
shapeFlag & ShapeFlags.FUNCTIONAL_COMPONENT) shapeFlag & ShapeFlags.FUNCTIONAL_COMPONENT)
) { ) {