Skip to content

Commit

Permalink
fix: Suspense should include into dynamic children (#653)
Browse files Browse the repository at this point in the history
fix #649
  • Loading branch information
underfin authored and yyx990803 committed Jan 22, 2020
1 parent 2569890 commit ec63623
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
35 changes: 34 additions & 1 deletion packages/runtime-core/__tests__/vnode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ describe('vnode', () => {
})

describe('dynamic children', () => {
test('single call openBlock', () => {
test('with patchFlags', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
Expand All @@ -259,5 +259,38 @@ describe('vnode', () => {
expect(vnode.dynamicChildren).toStrictEqual([vnode1, vnode2])
expect(vnode2.dynamicChildren).toStrictEqual([vnode3])
})

test('with stateful component', () => {

This comment has been minimized.

Copy link
@thecrypticace

thecrypticace Jan 25, 2020

Contributor

Are these tests doing anything? They don't appear to test the underlying problem this commit fixed.

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])
})
})
})
1 change: 1 addition & 0 deletions packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export function createVNode(
shouldTrack > 0 &&
currentBlock !== null &&
(patchFlag > 0 ||
shapeFlag & ShapeFlags.SUSPENSE ||
shapeFlag & ShapeFlags.STATEFUL_COMPONENT ||
shapeFlag & ShapeFlags.FUNCTIONAL_COMPONENT)
) {
Expand Down

0 comments on commit ec63623

Please sign in to comment.