UNPKG

nexora

Version:

A lightweight, production-ready JavaScript library for building user interfaces, supporting JSX.

21 lines (20 loc) 784 B
import { executeInitCallbacks } from '../../lifecycles/on-init'; import { mount } from './mount'; /** * Mount a component VNode * @description - This function is used to mount a component VNode. * @param vnode - The VNode to mount * @param container - The container element to mount the component in * @param nextSibling - The next sibling DOM node to mount the component after * @returns The DOM node for the component */ export function mountComponent(vnode, container, nextSibling = null) { const ComponentFn = vnode.type; const props = vnode.props; executeInitCallbacks(ComponentFn); const childVNode = props.children?.[0]; const dom = mount(childVNode, container, nextSibling); vnode._rendered = childVNode; vnode._dom = dom; return dom; }