mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix: sort vnode not work (#6100)
This commit is contained in:
parent
3188b4d25b
commit
177ef4d736
@ -18,17 +18,16 @@ function flattenVNodes(vnodes: VNode[]) {
|
||||
}
|
||||
|
||||
type VueInstance = {
|
||||
_vnode: VNode;
|
||||
$vnode: VNode;
|
||||
};
|
||||
|
||||
// sort children instances by vnodes order
|
||||
export function sortChildren(children: VueInstance[], parent: VueInstance) {
|
||||
// null on SSR
|
||||
if (!parent._vnode) {
|
||||
const { componentOptions } = parent.$vnode;
|
||||
if (!componentOptions || !componentOptions.children) {
|
||||
return;
|
||||
}
|
||||
|
||||
const vnodes = flattenVNodes(parent._vnode.children!);
|
||||
const vnodes = flattenVNodes(componentOptions.children);
|
||||
children.sort((a, b) => vnodes.indexOf(a.$vnode) - vnodes.indexOf(b.$vnode));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user