fix(range): clamp values that are out of bounds (#17623)

* fix(range): clamp out of bounds values, add tests

* lint files
This commit is contained in:
Liam DeBeasi
2019-03-01 12:22:53 -05:00
committed by GitHub
parent c475dab00b
commit 5a197ca1eb
2 changed files with 63 additions and 0 deletions

View File

@ -126,9 +126,27 @@ export class Range implements ComponentInterface {
if (!this.noUpdate) {
this.updateRatio();
}
value = this.ensureValueInBounds(value);
this.ionChange.emit({ value });
}
private clampBounds = (value: any): number => {
return clamp(this.min, value, this.max);
}
private ensureValueInBounds = (value: any) => {
if (this.dualKnobs) {
return {
lower: this.clampBounds(value.lower),
upper: this.clampBounds(value.upper)
};
} else {
return this.clampBounds(value);
}
}
/**
* Emitted when the value property has changed.
*/