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

Function createBaseVNode

packages/runtime-core/src/vnode.ts:456–540  ·  view source on GitHub ↗
(
  type: VNodeTypes | ClassComponent | typeof NULL_DYNAMIC_COMPONENT,
  props: (Data & VNodeProps) | null = null,
  children: unknown = null,
  patchFlag = 0,
  dynamicProps: string[] | null = null,
  shapeFlag: number = type === Fragment ? 0 : ShapeFlags.ELEMENT,
  isBlockNode = false,
  needFullChildrenNormalization = false,
)

Source from the content-addressed store, hash-verified

454}
455
456function createBaseVNode(
457 type: VNodeTypes | ClassComponent | typeof NULL_DYNAMIC_COMPONENT,
458 props: (Data & VNodeProps) | null = null,
459 children: unknown = null,
460 patchFlag = 0,
461 dynamicProps: string[] | null = null,
462 shapeFlag: number = type === Fragment ? 0 : ShapeFlags.ELEMENT,
463 isBlockNode = false,
464 needFullChildrenNormalization = false,
465): VNode {
466 const vnode = {
467 __v_isVNode: true,
468 __v_skip: true,
469 type,
470 props,
471 key: props && normalizeKey(props),
472 ref: props && normalizeRef(props),
473 scopeId: currentScopeId,
474 slotScopeIds: null,
475 children,
476 component: null,
477 suspense: null,
478 ssContent: null,
479 ssFallback: null,
480 dirs: null,
481 transition: null,
482 el: null,
483 anchor: null,
484 target: null,
485 targetStart: null,
486 targetAnchor: null,
487 staticCount: 0,
488 shapeFlag,
489 patchFlag,
490 dynamicProps,
491 dynamicChildren: null,
492 appContext: null,
493 ctx: currentRenderingInstance,
494 } as VNode
495
496 if (needFullChildrenNormalization) {
497 normalizeChildren(vnode, children)
498 // normalize suspense children
499 if (__FEATURE_SUSPENSE__ && shapeFlag & ShapeFlags.SUSPENSE) {
500 ;(type as typeof SuspenseImpl).normalize(vnode)
501 }
502 } else if (children) {
503 // compiled element vnode - if children is passed, only possible types are
504 // string or Array.
505 vnode.shapeFlag |= isString(children)
506 ? ShapeFlags.TEXT_CHILDREN
507 : ShapeFlags.ARRAY_CHILDREN
508 }
509
510 // validate key
511 if (__DEV__ && vnode.key !== vnode.key) {
512 warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type)
513 }

Callers 2

createElementBlockFunction · 0.85
_createVNodeFunction · 0.85

Calls 8

isStringFunction · 0.90
warnFunction · 0.90
convertLegacyVModelPropsFunction · 0.90
normalizeKeyFunction · 0.85
normalizeRefFunction · 0.85
normalizeChildrenFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected