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

Function mountComponent

packages/runtime-core/src/renderer.ts:1202–1280  ·  view source on GitHub ↗
(
    initialVNode,
    container,
    anchor,
    parentComponent,
    parentSuspense,
    namespace: ElementNamespace,
    optimized,
  )

Source from the content-addressed store, hash-verified

1200 }
1201
1202 const mountComponent: MountComponentFn = (
1203 initialVNode,
1204 container,
1205 anchor,
1206 parentComponent,
1207 parentSuspense,
1208 namespace: ElementNamespace,
1209 optimized,
1210 ) => {
1211 // 2.x compat may pre-create the component instance before actually
1212 // mounting
1213 const compatMountInstance =
1214 __COMPAT__ && initialVNode.isCompatRoot && initialVNode.component
1215 const instance: ComponentInternalInstance =
1216 compatMountInstance ||
1217 (initialVNode.component = createComponentInstance(
1218 initialVNode,
1219 parentComponent,
1220 parentSuspense,
1221 ))
1222
1223 if (__DEV__ && instance.type.__hmrId) {
1224 registerHMR(instance)
1225 }
1226
1227 if (__DEV__) {
1228 pushWarningContext(initialVNode)
1229 startMeasure(instance, `mount`)
1230 }
1231
1232 // inject renderer internals for keepAlive
1233 if (isKeepAlive(initialVNode)) {
1234 ;(instance.ctx as KeepAliveContext).renderer = internals
1235 }
1236
1237 // resolve props and slots for setup context
1238 if (!(__COMPAT__ && compatMountInstance)) {
1239 if (__DEV__) {
1240 startMeasure(instance, `init`)
1241 }
1242 setupComponent(instance, false, optimized)
1243 if (__DEV__) {
1244 endMeasure(instance, `init`)
1245 }
1246 }
1247
1248 // avoid hydration for hmr updating
1249 if (__DEV__ && isHmrUpdating) initialVNode.el = null
1250
1251 // setup() is async. This component relies on async logic to be resolved
1252 // before proceeding
1253 if (__FEATURE_SUSPENSE__ && instance.asyncDep) {
1254 parentSuspense &&
1255 parentSuspense.registerDep(instance, setupRenderEffect, optimized)
1256
1257 // Give it a placeholder if this is not hydration
1258 // TODO handle self-defined fallback
1259 if (!initialVNode.el) {

Callers 2

processComponentFunction · 0.85
hydrateNodeFunction · 0.85

Calls 11

createComponentInstanceFunction · 0.90
registerHMRFunction · 0.90
pushWarningContextFunction · 0.90
startMeasureFunction · 0.90
isKeepAliveFunction · 0.90
setupComponentFunction · 0.90
endMeasureFunction · 0.90
popWarningContextFunction · 0.90
processCommentNodeFunction · 0.85
setupRenderEffectFunction · 0.85
registerDepMethod · 0.80

Tested by

no test coverage detected