fix(runtime-core): dynamic component should support falsy values without warning

This commit is contained in:
Evan You
2020-04-24 15:06:21 -04:00
parent f3a9b516bd
commit ded92f93b4
3 changed files with 18 additions and 15 deletions

View File

@@ -8,7 +8,9 @@ import {
resolveDynamicComponent,
h,
serializeInner,
createVNode
createVNode,
Comment,
VNode
} from '@vue/runtime-test'
import { mockWarn } from '@vue/shared'
@@ -102,6 +104,7 @@ describe('resolveAssets', () => {
baz: { render: () => 'baz' }
}
let foo, bar, baz // dynamic components
let dynamicVNode: VNode
const Child = {
render(this: any) {
@@ -115,6 +118,7 @@ describe('resolveAssets', () => {
return () => {
foo = resolveDynamicComponent('foo') // <component is="foo"/>
bar = resolveDynamicComponent(dynamicComponents.bar) // <component :is="bar"/>, function
dynamicVNode = createVNode(resolveDynamicComponent(null)) // <component :is="null"/>
return h(Child, () => {
// check inside child slots
baz = resolveDynamicComponent(dynamicComponents.baz) // <component :is="baz"/>, object
@@ -129,6 +133,8 @@ describe('resolveAssets', () => {
expect(foo).toBe(dynamicComponents.foo)
expect(bar).toBe(dynamicComponents.bar)
expect(baz).toBe(dynamicComponents.baz)
// should allow explicit falsy type to remove the component
expect(dynamicVNode!.type).toBe(Comment)
})
test('resolve dynamic component should fallback to plain element without warning', () => {