From 6e25dc91606c56348d6339d23b09a0df5d086a64 Mon Sep 17 00:00:00 2001 From: Wibus <62133302+wibus-wee@users.noreply.github.com> Date: Thu, 22 Dec 2022 18:48:05 +0800 Subject: [PATCH] fix(core): missing checking vnode type in creating, fixed #19 (#20) --- packages/runtime/dom/dom.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/runtime/dom/dom.ts b/packages/runtime/dom/dom.ts index 6582292..25b2b08 100644 --- a/packages/runtime/dom/dom.ts +++ b/packages/runtime/dom/dom.ts @@ -10,7 +10,14 @@ import { camelToDash } from "../utils/others"; * * @param node the vnode */ -export function createElement(node: VNode): Node { +export function createElement(node: VNode | VNode[]): Node { + if (Array.isArray(node)) { + const fragment = document.createDocumentFragment(); + for (const child of node) { + fragment.appendChild(createElement(child)); + } + return fragment; + } // create a dom node according to the tag name of the vnode const el = node.tagName === "Fragment"