})
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]
}
}
}
}
- const App = {
- setup() {
- return () => {
- return h(Child, () => [h(Comp)])
- }
- }
- }
-
const root = nodeOps.createElement('div')
render(h(App), root)
expect(serializeInner(root)).toBe(`<h1></h1><h1></h1><h1></h1>`)
}
setupComponent(instance)
vnode.component = instance
+ vnode.isCompatRoot = true
// $mount & $destroy
// these are defined on ctx and picked up by the $mount/$destroy
) => {
// 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(
*/
[ReactiveFlags.SKIP]: true
+ /**
+ * @internal __COMPAT__ only
+ */
+ isCompatRoot?: true
+
type: VNodeTypes
props: (VNodeProps & ExtraProps) | null
key: string | number | null