diff --git a/packages/runtime-core/__tests__/rendererComponent.spec.ts b/packages/runtime-core/__tests__/rendererComponent.spec.ts index fc004045..4d20ca80 100644 --- a/packages/runtime-core/__tests__/rendererComponent.spec.ts +++ b/packages/runtime-core/__tests__/rendererComponent.spec.ts @@ -298,12 +298,10 @@ describe('renderer: component', () => { }) test('the component VNode should be cloned when reusing it', () => { - const Child = { - setup(props: any, { slots }: SetupContext) { - return () => { - const c = slots.default!() - return [c, c, c] - } + const App = { + render() { + const c = [h(Comp)] + return [c, c, c] } } @@ -315,14 +313,6 @@ describe('renderer: component', () => { } } - const App = { - setup() { - return () => { - return h(Child, () => [h(Comp)]) - } - } - } - const root = nodeOps.createElement('div') render(h(App), root) expect(serializeInner(root)).toBe(`
`) diff --git a/packages/runtime-core/src/compat/global.ts b/packages/runtime-core/src/compat/global.ts index 8b100254..3d518f44 100644 --- a/packages/runtime-core/src/compat/global.ts +++ b/packages/runtime-core/src/compat/global.ts @@ -472,6 +472,7 @@ function installCompatMount( } setupComponent(instance) vnode.component = instance + vnode.isCompatRoot = true // $mount & $destroy // these are defined on ctx and picked up by the $mount/$destroy diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index 1da8cd09..36291a24 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -1301,7 +1301,8 @@ function baseCreateRenderer( ) => { // 2.x compat may pre-creaate the component instance before actually // mounting - const compatMountInstance = __COMPAT__ && initialVNode.component + const compatMountInstance = + __COMPAT__ && initialVNode.isCompatRoot && initialVNode.component const instance: ComponentInternalInstance = compatMountInstance || (initialVNode.component = createComponentInstance( diff --git a/packages/runtime-core/src/vnode.ts b/packages/runtime-core/src/vnode.ts index da99f2ec..ec5a8f5d 100644 --- a/packages/runtime-core/src/vnode.ts +++ b/packages/runtime-core/src/vnode.ts @@ -136,6 +136,11 @@ export interface VNode< */ [ReactiveFlags.SKIP]: true + /** + * @internal __COMPAT__ only + */ + isCompatRoot?: true + type: VNodeTypes props: (VNodeProps & ExtraProps) | null key: string | number | null