(child: VNodeChild)
| 786 | } |
| 787 | |
| 788 | export 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 |
| 811 | export function cloneIfMounted(child: VNode): VNode { |
no test coverage detected