Skip to content

Commit

Permalink
fix: normalize default handle
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Jan 11, 2022
1 parent be69524 commit 89938a3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
7 changes: 6 additions & 1 deletion lib/mini-vue.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/mini-vue.cjs.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion lib/mini-vue.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/mini-vue.esm.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/runtime-core/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export function createTextVNode(text: string = " ") {
// 其目的是为了让 child 支持多种格式
export function normalizeVNode(child) {
// 暂时只支持处理 child 为 string 和 number 的情况
return createVNode(Text, null, String(child));
if (typeof child === "string" || typeof child === "number") {
return createVNode(Text, null, String(child));
} else {
return child;
}
}

// 基于 type 来判断是什么类型的组件
Expand Down

0 comments on commit 89938a3

Please sign in to comment.