From b310ec389d9738247e5b0f01711186216eb49955 Mon Sep 17 00:00:00 2001 From: auvred <61150013+auvred@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:08:46 +0300 Subject: [PATCH] fix(runtime-core): fix missed updates when passing text vnode to `` (#8304) close #8298 --- packages/runtime-core/__tests__/vnode.spec.ts | 11 +++++++++++ packages/runtime-core/src/vnode.ts | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/__tests__/vnode.spec.ts b/packages/runtime-core/__tests__/vnode.spec.ts index 29f5a042cc9..39a7abd5f89 100644 --- a/packages/runtime-core/__tests__/vnode.spec.ts +++ b/packages/runtime-core/__tests__/vnode.spec.ts @@ -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) diff --git a/packages/runtime-core/src/vnode.ts b/packages/runtime-core/src/vnode.ts index 3d30503e20a..d91532fb377 100644 --- a/packages/runtime-core/src/vnode.ts +++ b/packages/runtime-core/src/vnode.ts @@ -549,7 +549,7 @@ function _createVNode( currentBlock.push(cloned) } } - cloned.patchFlag |= PatchFlags.BAIL + cloned.patchFlag = PatchFlags.BAIL return cloned }