Skip to content

Commit

Permalink
fix(runtime-core): fix missed updates when passing text vnode to `<co…
Browse files Browse the repository at this point in the history
…mponent :is>` (#8304)

close #8298
  • Loading branch information
auvred authored Jun 5, 2024
1 parent 3b0a56a commit b310ec3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/runtime-core/__tests__/vnode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ describe('vnode', () => {
})
})

test('create from an existing text vnode', () => {
const vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT)
const vnode2 = createVNode(vnode1)
expect(vnode2).toMatchObject({
type: 'div',
patchFlag: PatchFlags.BAIL,
children: 'text',
shapeFlag: ShapeFlags.ELEMENT | ShapeFlags.TEXT_CHILDREN,
})
})

test('vnode keys', () => {
for (const key of ['', 'a', 0, 1, NaN]) {
expect(createVNode('div', { key }).key).toBe(key)
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ function _createVNode(
currentBlock.push(cloned)
}
}
cloned.patchFlag |= PatchFlags.BAIL
cloned.patchFlag = PatchFlags.BAIL
return cloned
}

Expand Down

0 comments on commit b310ec3

Please sign in to comment.