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

Function normalizeVNode

packages/runtime-core/src/vnode.ts:788–808  ·  view source on GitHub ↗
(child: VNodeChild)

Source from the content-addressed store, hash-verified

786}
787
788export function normalizeVNode(child: VNodeChild): VNode {
789 if (child == null || typeof child === 'boolean') {
790 // empty placeholder
791 return createVNode(Comment)
792 } else if (isArray(child)) {
793 // fragment
794 return createVNode(
795 Fragment,
796 null,
797 // #3666, avoid reference pollution when reusing vnode
798 child.slice(),
799 )
800 } else if (isVNode(child)) {
801 // already vnode, this should be the most common since compiled templates
802 // always produce all-vnode children arrays
803 return cloneIfMounted(child)
804 } else {
805 // strings and numbers
806 return createVNode(Text, null, String(child))
807 }
808}
809
810// optimized normalization for template-compiled render fns
811export function cloneIfMounted(child: VNode): VNode {

Callers 11

normalizeSlotValueFunction · 0.90
mountChildrenFunction · 0.90
patchUnkeyedChildrenFunction · 0.90
patchKeyedChildrenFunction · 0.90
hydrateChildrenFunction · 0.90
renderComponentRootFunction · 0.90
getChildRootFunction · 0.90
normalizeSuspenseSlotFunction · 0.90
vnode.spec.tsFile · 0.90
renderVNodeChildrenFunction · 0.85

Calls 3

isVNodeFunction · 0.85
cloneIfMountedFunction · 0.85
StringInterface · 0.85

Tested by

no test coverage detected