Skip to content

Commit

Permalink
refactor: simplify observer logic
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Sep 30, 2024
1 parent 6ce618d commit 4726554
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions packages/custom-field/src/vaadin-custom-field-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const CustomFieldMixin = (superClass) =>
inputs: {
type: Array,
readOnly: true,
observer: '__inputsChanged',
},

/**
Expand Down Expand Up @@ -108,10 +109,6 @@ export const CustomFieldMixin = (superClass) =>
};
}

static get observers() {
return ['__inputsOrValueChanged(inputs, value)'];
}

/** @protected */
ready() {
super.ready();
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 4726554

Please sign in to comment.