Skip to content

Commit 5770110

Browse files
committed
fix(range): catching range with an invalid value on first load
1 parent cdbcd56 commit 5770110

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/src/components/range/range.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ export class Range implements ComponentInterface {
110110
@Prop() min = 0;
111111
@Watch('min')
112112
protected minChanged(newValue: number) {
113-
console.log('minChanged', newValue);
114113
if (!isSafeNumber(newValue)) {
115-
console.log('minChanged not safe', newValue);
116114
this.min = 0;
117115
}
118116

@@ -127,9 +125,7 @@ export class Range implements ComponentInterface {
127125
@Prop() max = 100;
128126
@Watch('max')
129127
protected maxChanged(newValue: number) {
130-
console.log('maxChanged', newValue);
131128
if (!isSafeNumber(newValue)) {
132-
console.log('maxChanged not safe', newValue);
133129
this.max = 100;
134130
}
135131

@@ -312,6 +308,10 @@ export class Range implements ComponentInterface {
312308
}
313309

314310
this.inheritedAttributes = inheritAriaAttributes(this.el);
311+
// If the min or max is not safe, set it to 0 or 100 respectively.
312+
// Our watch does this, but not before the initial load.
313+
this.min = isSafeNumber(this.min) ? this.min : 0;
314+
this.max = isSafeNumber(this.max) ? this.max : 100;
315315
}
316316

317317
componentDidLoad() {

0 commit comments

Comments
 (0)