let currentVNode: VNode | null = null
let currentContextVNode: VNode | null = null
-export function createComponentInstance(
- vnode: VNode,
- Component: ComponentClass
+export function createComponentInstance<T extends Component>(
+ vnode: VNode
): ComponentInstance {
// component instance creation is done in two steps.
// first, `initializeComponentInstance` is called inside base component
// always pass args in super()
currentVNode = vnode
currentContextVNode = vnode.contextVNode
+ const Component = vnode.tag as ComponentClass
const instance = (vnode.children = new Component() as ComponentInstance)
// then we finish the initialization by collecting properties set on the
Ref,
VNodeChildren
} from './vdom'
-import {
- ComponentInstance,
- FunctionalComponent,
- ComponentClass
-} from './component'
+import { ComponentInstance, FunctionalComponent } from './component'
import { updateProps } from './componentProps'
import {
renderInstanceRoot,
// kept-alive
activateComponentInstance(vnode, container, endNode)
} else {
- mountComponentInstance(
- vnode,
- vnode.tag as ComponentClass,
- container,
- isSVG,
- endNode
- )
+ mountComponentInstance(vnode, container, isSVG, endNode)
}
}
function mountComponentInstance(
vnode: VNode,
- Component: ComponentClass,
container: RenderNode | null,
isSVG: boolean,
endNode: RenderNode | null
): RenderNode {
// a vnode may already have an instance if this is a compat call with
// new Vue()
- const instance =
- (__COMPAT__ && (vnode.children as ComponentInstance)) ||
- createComponentInstance(vnode, Component)
+ const instance = ((__COMPAT__ && vnode.children) ||
+ createComponentInstance(vnode as any)) as ComponentInstance
// inject platform-specific unmount to keep-alive container
- if ((Component as any)[KeepAliveSymbol] === true) {
+ if ((vnode.tag as any)[KeepAliveSymbol] === true) {
;(instance as any).$unmount = unmountComponentInstance
}
// convert it to a class
const Component = createComponentClassFromOptions(options || {})
const vnode = h(Component)
- const instance = createComponentInstance(vnode, Component)
+ const instance = createComponentInstance(vnode)
function mount(el: any) {
const dom = typeof el === 'string' ? document.querySelector(el) : el