fix(Form): incorrect validation order when add field dynamically

This commit is contained in:
chenjiahan
2020-04-01 21:39:08 +08:00
committed by neverland
parent 02e67fdd47
commit b8dea3c13b
5 changed files with 79 additions and 24 deletions
+4 -22
View File
@@ -1,26 +1,10 @@
import Vue, { VNode } from 'vue';
import Vue from 'vue';
import { sortChildren } from '../utils/vnodes';
type ChildrenMixinOptions = {
indexKey?: any;
};
function flattenVNodes(vnodes: VNode[]) {
const result: VNode[] = [];
function traverse(vnodes: VNode[]) {
vnodes.forEach(vnode => {
result.push(vnode);
if (vnode.children) {
traverse(vnode.children);
}
});
}
traverse(vnodes);
return result;
}
type ChildrenMixinThis = {
disableBindRelation?: boolean;
};
@@ -72,10 +56,8 @@ export function ChildrenMixin(
}
const children = [...this.parent.children, this];
const vnodes = flattenVNodes(this.parent.slots());
children.sort(
(a, b) => vnodes.indexOf(a.$vnode) - vnodes.indexOf(b.$vnode)
);
sortChildren(children, this.parent);
this.parent.children = children;
},