Skip to content

Commit ec63623

Browse files
underfinyyx990803
authored andcommitted
fix: Suspense should include into dynamic children (#653)
fix #649
1 parent 2569890 commit ec63623

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

packages/runtime-core/__tests__/vnode.spec.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ describe('vnode', () => {
232232
})
233233

234234
describe('dynamic children', () => {
235-
test('single call openBlock', () => {
235+
test('with patchFlags', () => {
236236
const hoist = createVNode('div')
237237
let vnode1
238238
const vnode = (openBlock(),
@@ -259,5 +259,38 @@ describe('vnode', () => {
259259
expect(vnode.dynamicChildren).toStrictEqual([vnode1, vnode2])
260260
expect(vnode2.dynamicChildren).toStrictEqual([vnode3])
261261
})
262+
263+
test('with stateful component', () => {
264+
const hoist = createVNode('div')
265+
let vnode1
266+
const vnode = (openBlock(),
267+
createBlock('div', null, [
268+
hoist,
269+
(vnode1 = createVNode({}, null, 'text'))
270+
]))
271+
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
272+
})
273+
274+
test('with functional component', () => {
275+
const hoist = createVNode('div')
276+
let vnode1
277+
const vnode = (openBlock(),
278+
createBlock('div', null, [
279+
hoist,
280+
(vnode1 = createVNode(() => {}, null, 'text'))
281+
]))
282+
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
283+
})
284+
285+
test('with suspense', () => {
286+
const hoist = createVNode('div')
287+
let vnode1
288+
const vnode = (openBlock(),
289+
createBlock('div', null, [
290+
hoist,
291+
(vnode1 = createVNode(() => {}, null, 'text'))
292+
]))
293+
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
294+
})
262295
})
263296
})

packages/runtime-core/src/vnode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ export function createVNode(
274274
shouldTrack > 0 &&
275275
currentBlock !== null &&
276276
(patchFlag > 0 ||
277+
shapeFlag & ShapeFlags.SUSPENSE ||
277278
shapeFlag & ShapeFlags.STATEFUL_COMPONENT ||
278279
shapeFlag & ShapeFlags.FUNCTIONAL_COMPONENT)
279280
) {

0 commit comments

Comments
 (0)