Ver código fonte

fix(core): use String to convert primitive types (#518)

meteorlxy 6 anos atrás
pai
commit
f3007a6b4f
1 arquivos alterados com 2 adições e 2 exclusões
  1. 2 2
      packages/runtime-core/src/vnode.ts

+ 2 - 2
packages/runtime-core/src/vnode.ts

@@ -336,7 +336,7 @@ export function normalizeVNode<T, U>(child: VNodeChild<T, U>): VNode<T, U> {
     return child.el === null ? child : cloneVNode(child)
   } else {
     // primitive types
-    return createVNode(Text, null, child + '')
+    return createVNode(Text, null, String(child))
   }
 }
 
@@ -352,7 +352,7 @@ export function normalizeChildren(vnode: VNode, children: unknown) {
     children = { default: children }
     type = ShapeFlags.SLOTS_CHILDREN
   } else {
-    children = isString(children) ? children : children + ''
+    children = String(children)
     type = ShapeFlags.TEXT_CHILDREN
   }
   vnode.children = children as NormalizedChildren