types: improve vnode utils typing

This commit is contained in:
chenjiahan 2020-04-01 21:21:46 +08:00 committed by neverland
parent b8dea3c13b
commit 36dbf0c4e0

View File

@ -18,8 +18,13 @@ function flattenVNodes(vnodes: VNode[]) {
return result;
}
type VueInstance = {
_vnode: VNode;
$vnode: VNode;
};
// sort children instances by vnodes order
export function sortChildren(children: any[], parent: any) {
const vnodes = flattenVNodes(parent._vnode.children);
export function sortChildren(children: VueInstance[], parent: VueInstance) {
const vnodes = flattenVNodes(parent._vnode.children!);
children.sort((a, b) => vnodes.indexOf(a.$vnode) - vnodes.indexOf(b.$vnode));
}