perf: avoid multiple decorator when FormItem is nested

pull/471/head
tangjinzhou 2019-02-02 15:25:43 +08:00
parent 55a8dca9e7
commit 9a463899fb
1 changed files with 7 additions and 3 deletions

View File

@ -434,7 +434,11 @@ export default {
decoratorChildren(vnodes) {
const { FormProps } = this;
const getFieldDecorator = FormProps.form.getFieldDecorator;
vnodes.forEach((vnode, index) => {
for (let i = 0, len = vnodes.length; i < len; i++) {
const vnode = vnodes[i];
if (getSlotOptions(vnode).__ANT_FORM_ITEM) {
break;
}
if (vnode.children) {
vnode.children = this.decoratorChildren(cloneVNodes(vnode.children));
} else if (vnode.componentOptions && vnode.componentOptions.children) {
@ -444,9 +448,9 @@ export default {
}
const option = this.decoratorOption(vnode);
if (option && option[0]) {
vnodes[index] = getFieldDecorator(option[0], option[1])(vnode);
vnodes[i] = getFieldDecorator(option[0], option[1])(vnode);
}
}
});
return vnodes;
},
},