From 47265547f707a0730dbaa6ecdcd29a8efcf2fd0b Mon Sep 17 00:00:00 2001 From: web-padawan Date: Mon, 30 Sep 2024 12:59:58 +0300 Subject: [PATCH] refactor: simplify observer logic --- .../src/vaadin-custom-field-mixin.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/custom-field/src/vaadin-custom-field-mixin.js b/packages/custom-field/src/vaadin-custom-field-mixin.js index d31911eb36..bd85373f6e 100644 --- a/packages/custom-field/src/vaadin-custom-field-mixin.js +++ b/packages/custom-field/src/vaadin-custom-field-mixin.js @@ -65,6 +65,7 @@ export const CustomFieldMixin = (superClass) => inputs: { type: Array, readOnly: true, + observer: '__inputsChanged', }, /** @@ -108,10 +109,6 @@ export const CustomFieldMixin = (superClass) => }; } - static get observers() { - return ['__inputsOrValueChanged(inputs, value)']; - } - /** @protected */ ready() { super.ready(); @@ -256,19 +253,15 @@ export const CustomFieldMixin = (superClass) => } /** @private */ - __inputsOrValueChanged(inputs, value) { - const oldInputs = this.__oldInputs; - - if (inputs && inputs !== oldInputs && inputs.length > 0) { + __inputsChanged(inputs, oldInputs) { + if (inputs !== oldInputs && inputs.length > 0) { // When inputs are first initialized, apply value set with property. - if (value && value !== '\t' && (!oldInputs || oldInputs.length === 0)) { - this.__applyInputsValue(value); + if (this.value && this.value !== '\t' && (!oldInputs || oldInputs.length === 0)) { + this.__applyInputsValue(this.value); } else { this.__setValue(); } } - - this.__oldInputs = inputs; } /** @private */