fix: sort vnode not work (#6100)

This commit is contained in:
neverland 2020-04-20 19:33:28 +08:00 committed by chenjiahan
parent 6a992793b4
commit 4dc423993d

View File

@ -18,17 +18,16 @@ function flattenVNodes(vnodes: VNode[]) {
} }
type VueInstance = { type VueInstance = {
_vnode: VNode;
$vnode: VNode; $vnode: VNode;
}; };
// sort children instances by vnodes order // sort children instances by vnodes order
export function sortChildren(children: VueInstance[], parent: VueInstance) { export function sortChildren(children: VueInstance[], parent: VueInstance) {
// null on SSR const { componentOptions } = parent.$vnode;
if (!parent._vnode) { if (!componentOptions || !componentOptions.children) {
return; return;
} }
const vnodes = flattenVNodes(parent._vnode.children!); const vnodes = flattenVNodes(componentOptions.children);
children.sort((a, b) => vnodes.indexOf(a.$vnode) - vnodes.indexOf(b.$vnode)); children.sort((a, b) => vnodes.indexOf(a.$vnode) - vnodes.indexOf(b.$vnode));
} }