let uid = 0
export const createComponentInstance = (
- component: BlockFn
+ component: BlockFn,
): ComponentInternalInstance => {
const instance: ComponentInternalInstance = {
uid: uid++,
scope: new EffectScope(true /* detached */)!,
component,
- isMounted: false
+ isMounted: false,
// TODO: registory of provides, appContext, lifecycles, ...
}
return instance
isArray,
normalizeClass,
normalizeStyle,
- toDisplayString
+ toDisplayString,
} from '@vue/shared'
import { ComponentInternalInstance, createComponentInstance } from './component'
export function render(
comp: BlockFn,
- container: string | ParentNode
+ container: string | ParentNode,
): ComponentInternalInstance {
const instance = createComponentInstance(comp)
mountComponent(instance, (container = normalizeContainer(container)))
export const mountComponent = (
instance: ComponentInternalInstance,
- container: ParentNode
+ container: ParentNode,
) => {
instance.container = container
const block = instance.scope.run(
- () => (instance.block = instance.component())
+ () => (instance.block = instance.component()),
)!
insert(block, instance.container)
instance.isMounted = true
export function insert(
block: Block,
parent: ParentNode,
- anchor: Node | null = null
+ anchor: Node | null = null,
) {
// if (!isHydrating) {
if (block instanceof Node) {
type Children = Record<number, [ChildNode, Children]>
export function children(n: ChildNode): Children {
- return { ...Array.from(n.childNodes).map(n => [n, children(n)]) }
+ return { ...Array.from(n.childNodes).map((n) => [n, children(n)]) }
}
export function createTextNode(val: unknown): Text {