fix: sortChildren broke SSR (#6046)

This commit is contained in:
neverland 2020-04-14 09:52:50 +08:00 committed by GitHub
parent 77f6b7a19a
commit 14c18c6b8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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