File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
core/src/components/range Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -213,9 +213,9 @@ export class Range implements ComponentInterface {
213213 */
214214 @Prop ( { mutable : true } ) value : RangeValue = 0 ;
215215 @Watch ( 'value' )
216- protected valueChanged ( newVlue : RangeValue , oldValue : RangeValue ) {
217- // The check is necessary because the value can be an object.
218- if ( JSON . stringify ( newVlue ) !== JSON . stringify ( oldValue ) ) {
216+ protected valueChanged ( newValue : RangeValue , oldValue : RangeValue ) {
217+ const valuesChanged = this . areValuesDifferent ( newValue , oldValue ) ;
218+ if ( valuesChanged ) {
219219 this . ionInput . emit ( { value : this . value } ) ;
220220 }
221221
@@ -224,6 +224,21 @@ export class Range implements ComponentInterface {
224224 }
225225 }
226226
227+ /**
228+ * Compares two RangeValue inputs to determine if they are different.
229+ *
230+ * @param newVal - The new value.
231+ * @param oldVal - The old value.
232+ * @returns `true` if the values are different, `false` otherwise.
233+ */
234+ private areValuesDifferent = ( newVal : RangeValue , oldVal : RangeValue ) => {
235+ if ( typeof newVal === 'object' && typeof oldVal === 'object' ) {
236+ return newVal . lower !== oldVal . lower || newVal . upper !== oldVal . upper ;
237+ }
238+
239+ return newVal !== oldVal ;
240+ } ;
241+
227242 private clampBounds = ( value : any ) : number => {
228243 return clamp ( this . min , value , this . max ) ;
229244 } ;
You can’t perform that action at this time.
0 commit comments