Skip to content

Commit 9a46389

Browse files
committed
perf: avoid multiple decorator when FormItem is nested
1 parent 55a8dca commit 9a46389

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

components/form/FormItem.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,11 @@ export default {
434434
decoratorChildren(vnodes) {
435435
const { FormProps } = this;
436436
const getFieldDecorator = FormProps.form.getFieldDecorator;
437-
vnodes.forEach((vnode, index) => {
437+
for (let i = 0, len = vnodes.length; i < len; i++) {
438+
const vnode = vnodes[i];
439+
if (getSlotOptions(vnode).__ANT_FORM_ITEM) {
440+
break;
441+
}
438442
if (vnode.children) {
439443
vnode.children = this.decoratorChildren(cloneVNodes(vnode.children));
440444
} else if (vnode.componentOptions && vnode.componentOptions.children) {
@@ -444,9 +448,9 @@ export default {
444448
}
445449
const option = this.decoratorOption(vnode);
446450
if (option && option[0]) {
447-
vnodes[index] = getFieldDecorator(option[0], option[1])(vnode);
451+
vnodes[i] = getFieldDecorator(option[0], option[1])(vnode);
448452
}
449-
});
453+
}
450454
return vnodes;
451455
},
452456
},

0 commit comments

Comments
 (0)