Remove dead code and make sure the number-changed event isn't send double.
This commit is contained in:
parent
bd5d079ed6
commit
d21cd85d4f
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tp/tp-number-input",
|
"name": "@tp/tp-number-input",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "tp-number-input.js",
|
"main": "tp-number-input.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -146,7 +146,7 @@ class TpNumberInput extends FormElement(EventHelpers(DomQuery(LitElement))) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (changes.has('value') || changes.has('min') || changes.has('max') || changes.has('suffix') || changes.has('ignoreSuffix') || changes.has('timeMode')) {
|
if (changes.has('value') || changes.has('min') || changes.has('max') || changes.has('suffix') || changes.has('ignoreSuffix') || changes.has('timeMode')) {
|
||||||
this._updateValue(this.value);
|
this._updateValue(this.value, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,17 +325,7 @@ class TpNumberInput extends FormElement(EventHelpers(DomQuery(LitElement))) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_internValueChanged(val) {
|
_updateValue(val, skipEvent) {
|
||||||
if(val === '') return;
|
|
||||||
|
|
||||||
if(this.timeMode) {
|
|
||||||
this._timeValueChanged(val);
|
|
||||||
} else {
|
|
||||||
this._updateValue(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateValue(val) {
|
|
||||||
if(this.timeMode) return;
|
if(this.timeMode) return;
|
||||||
|
|
||||||
const oldValue = this.value;
|
const oldValue = this.value;
|
||||||
@ -344,11 +334,7 @@ class TpNumberInput extends FormElement(EventHelpers(DomQuery(LitElement))) {
|
|||||||
this.value = this.specialMin;
|
this.value = this.specialMin;
|
||||||
this.$.input.value = this.value;
|
this.$.input.value = this.value;
|
||||||
if (oldValue !== this.value && this._isConnected) {
|
if (oldValue !== this.value && this._isConnected) {
|
||||||
this.dispatchEvent(new CustomEvent('number-changed', {
|
if (!skipEvent) this.dispatchEvent(new CustomEvent('number-changed', { detail: { value: this.value }, bubbles: true, composed: true }));
|
||||||
detail: { value: this.value },
|
|
||||||
bubbles: true,
|
|
||||||
composed: true
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -365,11 +351,7 @@ class TpNumberInput extends FormElement(EventHelpers(DomQuery(LitElement))) {
|
|||||||
this.value = this.specialMin;
|
this.value = this.specialMin;
|
||||||
this.$.input.value = this.value;
|
this.$.input.value = this.value;
|
||||||
if (oldValue !== this.value && this._isConnected) {
|
if (oldValue !== this.value && this._isConnected) {
|
||||||
this.dispatchEvent(new CustomEvent('number-changed', {
|
if (!skipEvent) this.dispatchEvent(new CustomEvent('number-changed', { detail: { value: this.value }, bubbles: true, composed: true }));
|
||||||
detail: { value: this.value },
|
|
||||||
bubbles: true,
|
|
||||||
composed: true
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -380,11 +362,7 @@ class TpNumberInput extends FormElement(EventHelpers(DomQuery(LitElement))) {
|
|||||||
this.$.input.value = !!this.suffix ? val + this.suffix : val;
|
this.$.input.value = !!this.suffix ? val + this.suffix : val;
|
||||||
|
|
||||||
if (oldValue !== this.value && this._isConnected) {
|
if (oldValue !== this.value && this._isConnected) {
|
||||||
this.dispatchEvent(new CustomEvent('number-changed', {
|
if (!skipEvent) this.dispatchEvent(new CustomEvent('number-changed', { detail: { value: this.value }, bubbles: true, composed: true }));
|
||||||
detail: { value: this.value },
|
|
||||||
bubbles: true,
|
|
||||||
composed: true
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user