MCPcopy
hub / github.com/vuejs/core / mountElement

Function mountElement

packages/runtime-core/src/renderer.ts:654–754  ·  view source on GitHub ↗
(
    vnode: VNode,
    container: RendererElement,
    anchor: RendererNode | null,
    parentComponent: ComponentInternalInstance | null,
    parentSuspense: SuspenseBoundary | null,
    namespace: ElementNamespace,
    slotScopeIds: string[] | null,
    optimized: boolean,
  )

Source from the content-addressed store, hash-verified

652 }
653
654 const mountElement = (
655 vnode: VNode,
656 container: RendererElement,
657 anchor: RendererNode | null,
658 parentComponent: ComponentInternalInstance | null,
659 parentSuspense: SuspenseBoundary | null,
660 namespace: ElementNamespace,
661 slotScopeIds: string[] | null,
662 optimized: boolean,
663 ) => {
664 let el: RendererElement
665 let vnodeHook: VNodeHook | undefined | null
666 const { props, shapeFlag, transition, dirs } = vnode
667
668 el = vnode.el = hostCreateElement(
669 vnode.type as string,
670 namespace,
671 props && props.is,
672 props,
673 )
674
675 // mount children first, since some props may rely on child content
676 // being already rendered, e.g. `<select value>`
677 if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
678 hostSetElementText(el, vnode.children as string)
679 } else if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
680 mountChildren(
681 vnode.children as VNodeArrayChildren,
682 el,
683 null,
684 parentComponent,
685 parentSuspense,
686 resolveChildrenNamespace(vnode, namespace),
687 slotScopeIds,
688 optimized,
689 )
690 }
691
692 if (dirs) {
693 invokeDirectiveHook(vnode, null, parentComponent, 'created')
694 }
695 // scopeId
696 setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent)
697 // props
698 if (props) {
699 for (const key in props) {
700 if (key !== 'value' && !isReservedProp(key)) {
701 hostPatchProp(el, key, null, props[key], namespace, parentComponent)
702 }
703 }
704 /**
705 * Special case for setting value on DOM elements:
706 * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
707 * - it needs to be forced (#1471)
708 * #2353 proposes adding another renderer option to configure this, but
709 * the properties affects are so finite it is worth special casing it
710 * here to reduce the complexity. (Special casing it also should not
711 * affect non-DOM renderers)

Callers 1

processElementFunction · 0.85

Calls 10

invokeDirectiveHookFunction · 0.90
invokeVNodeHookFunction · 0.90
defFunction · 0.90
setHmrUpdatingFunction · 0.90
mountChildrenFunction · 0.85
resolveChildrenNamespaceFunction · 0.85
needTransitionFunction · 0.85
beforeEnterMethod · 0.80
enterMethod · 0.80
setScopeIdFunction · 0.70

Tested by

no test coverage detected