return true
}
- if (patchFlag > 0) {
+ if (optimized && patchFlag > 0) {
if (patchFlag & PatchFlags.DYNAMIC_SLOTS) {
// slot content that references values that might have changed,
// e.g. in a v-for
}
}
}
- } else if (!optimized) {
+ } else {
// this path is only taken by manually written render functions
// so presence of any children leads to a forced update
if (prevChildren || nextChildren) {
}
if (isVNode(type)) {
- return cloneVNode(type, props, children)
+ const cloned = cloneVNode(type, props)
+ if (children) {
+ normalizeChildren(cloned, children)
+ }
+ return cloned
}
// class component normalization.
export function cloneVNode<T, U>(
vnode: VNode<T, U>,
- extraProps?: Data & VNodeProps | null,
- children?: unknown
+ extraProps?: Data & VNodeProps | null
): VNode<T, U> {
const props = extraProps
? vnode.props
: vnode.props
// This is intentionally NOT using spread or extend to avoid the runtime
// key enumeration cost.
- const cloned: VNode<T, U> = {
+ return {
__v_isVNode: true,
__v_skip: true,
type: vnode.type,
staticCount: vnode.staticCount,
shapeFlag: vnode.shapeFlag,
// if the vnode is cloned with extra props, we can no longer assume its
- // existing patch flag to be reliable and need to bail out of optimized mode.
- // however we don't want block nodes to de-opt their children, so if the
- // vnode is a block node, we only add the FULL_PROPS flag to it.
- patchFlag: extraProps
- ? vnode.dynamicChildren
+ // existing patch flag to be reliable and need to add the FULL_PROPS flag.
+ patchFlag:
+ extraProps && vnode.type !== Fragment
? vnode.patchFlag | PatchFlags.FULL_PROPS
- : PatchFlags.BAIL
- : vnode.patchFlag,
+ : vnode.patchFlag,
dynamicProps: vnode.dynamicProps,
dynamicChildren: vnode.dynamicChildren,
appContext: vnode.appContext,
el: vnode.el,
anchor: vnode.anchor
}
- if (children) {
- normalizeChildren(cloned, children)
- }
- return cloned
}
/**