Răsfoiți Sursa

fix(runtime-core): fix missed updates when passing text vnode to `<component :is>` (#8304)

close #8298
auvred 1 an în urmă
părinte
comite
b310ec389d

+ 11 - 0
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)

+ 1 - 1
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
   }