From cd248b767828fb7effbf8bec2cc738412a20ffde Mon Sep 17 00:00:00 2001 From: Zaytsev Kirill Date: Fri, 23 Oct 2020 13:24:27 +0300 Subject: [PATCH] refactor: Decrease of code block nesting --- src/FormularioForm.vue | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/FormularioForm.vue b/src/FormularioForm.vue index 175f9d3..47e3d8a 100644 --- a/src/FormularioForm.vue +++ b/src/FormularioForm.vue @@ -148,22 +148,24 @@ export default class FormularioForm extends Vue { const keys = Array.from(new Set([...Object.keys(values), ...Object.keys(this.proxy)])) let proxyHasChanges = false keys.forEach(field => { - if (this.registry.hasNested(field)) { - this.registry.getNested(field).forEach((registryField, registryKey) => { - const $input = this.registry.get(registryKey) as FormularioInput - const oldValue = getNested(this.proxy, registryKey) - const newValue = getNested(values, registryKey) - - if (!shallowEqualObjects(newValue, oldValue)) { - this.setFieldValue(registryKey, newValue, false) - proxyHasChanges = true - } - - if (!shallowEqualObjects(newValue, $input.proxy)) { - $input.context.model = newValue - } - }) + if (!this.registry.hasNested(field)) { + return } + + this.registry.getNested(field).forEach((registryField, registryKey) => { + const $input = this.registry.get(registryKey) as FormularioInput + const oldValue = getNested(this.proxy, registryKey) + const newValue = getNested(values, registryKey) + + if (!shallowEqualObjects(newValue, oldValue)) { + this.setFieldValue(registryKey, newValue, false) + proxyHasChanges = true + } + + if (!shallowEqualObjects(newValue, $input.proxy)) { + $input.context.model = newValue + } + }) }) this.initProxy()