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

Function _createVNode

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

Source from the content-addressed store, hash-verified

546) as typeof _createVNode
547
548function _createVNode(
549 type: VNodeTypes | ClassComponent | typeof NULL_DYNAMIC_COMPONENT,
550 props: (Data & VNodeProps) | null = null,
551 children: unknown = null,
552 patchFlag: number = 0,
553 dynamicProps: string[] | null = null,
554 isBlockNode = false,
555): VNode {
556 if (!type || type === NULL_DYNAMIC_COMPONENT) {
557 if (__DEV__ && !type) {
558 warn(`Invalid vnode type when creating vnode: ${type}.`)
559 }
560 type = Comment
561 }
562
563 if (isVNode(type)) {
564 // createVNode receiving an existing vnode. This happens in cases like
565 // <component :is="vnode"/>
566 // #2078 make sure to merge refs during the clone instead of overwriting it
567 const cloned = cloneVNode(type, props, true /* mergeRef: true */)
568 if (children) {
569 normalizeChildren(cloned, children)
570 }
571 if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
572 if (cloned.shapeFlag & ShapeFlags.COMPONENT) {
573 currentBlock[currentBlock.indexOf(type)] = cloned
574 } else {
575 currentBlock.push(cloned)
576 }
577 }
578 cloned.patchFlag = PatchFlags.BAIL
579 return cloned
580 }
581
582 // class component normalization.
583 if (isClassComponent(type)) {
584 type = type.__vccOpts
585 }
586
587 // 2.x async/functional component compat
588 if (__COMPAT__) {
589 type = convertLegacyComponent(type, currentRenderingInstance)
590 }
591
592 // class & style normalization.
593 if (props) {
594 // for reactive or proxy objects, we need to clone it to enable mutation.
595 props = guardReactiveProps(props)!
596 let { class: klass, style } = props
597 if (klass && !isString(klass)) {
598 props.class = normalizeClass(klass)
599 }
600 if (isObject(style)) {
601 // reactive state objects need to be cloned since they are likely to be
602 // mutated
603 if (isProxy(style) && !isArray(style)) {
604 style = extend({}, style)
605 }

Callers 1

Calls 15

warnFunction · 0.90
isClassComponentFunction · 0.90
convertLegacyComponentFunction · 0.90
isStringFunction · 0.90
normalizeClassFunction · 0.90
isObjectFunction · 0.90
isProxyFunction · 0.90
normalizeStyleFunction · 0.90
isSuspenseFunction · 0.90
isTeleportFunction · 0.90
isFunctionFunction · 0.90
toRawFunction · 0.90

Tested by

no test coverage detected