feat(transition): compat with keep-alive

This commit is contained in:
Evan You
2019-11-25 17:34:28 -05:00
parent 16ea2993d6
commit c6fb506fc0
8 changed files with 192 additions and 88 deletions

View File

@@ -1,8 +1,9 @@
import { ComponentInternalInstance, currentInstance } from './component'
import { VNode, NormalizedChildren, normalizeVNode, VNodeChild } from './vnode'
import { isArray, isFunction } from '@vue/shared'
import { isArray, isFunction, EMPTY_OBJ } from '@vue/shared'
import { ShapeFlags } from './shapeFlags'
import { warn } from './warning'
import { isKeepAlive } from './components/KeepAlive'
export type Slot = (...args: any[]) => VNode[]
@@ -65,7 +66,7 @@ export function resolveSlots(
}
} else if (children !== null) {
// non slot object children (direct value) passed to a component
if (__DEV__) {
if (__DEV__ && !isKeepAlive(instance.vnode)) {
warn(
`Non-function value encountered for default slot. ` +
`Prefer function slots for better performance.`
@@ -74,7 +75,5 @@ export function resolveSlots(
const normalized = normalizeSlotValue(children)
slots = { default: () => normalized }
}
if (slots !== void 0) {
instance.slots = slots
}
instance.slots = slots || EMPTY_OBJ
}