152152<script lang="ts">
153153import { defineComponent , PropType } from " vue" ;
154154
155- import { clamp } from " @/utilities/math" ;
156-
157155export type IncrementBehavior = " Add" | " Multiply" | " Callback" | " None" ;
158156export type IncrementDirection = " Decrease" | " Increase" ;
159157
@@ -242,17 +240,18 @@ export default defineComponent({
242240 if (invalid ) sanitized = this .value ;
243241
244242 if (this .isInteger ) sanitized = Math .round (sanitized );
245- sanitized = clamp (newValue , this .min , this .max );
243+ if (typeof this .min === " number" && ! Number .isNaN (this .min )) sanitized = Math .max (sanitized , this .min );
244+ if (typeof this .max === " number" && ! Number .isNaN (this .max )) sanitized = Math .min (sanitized , this .max );
246245
247246 if (! invalid ) this .$emit (" update:value" , sanitized );
248247
249248 this .setText (sanitized );
250249 },
251250 setText(value : number ) {
252- // Find the amount of digits on the left side of the Decimal
251+ // Find the amount of digits on the left side of the decimal
253252 // 10.25 == 2
254253 // 1.23 == 1
255- // 0.23 == 0 - Reason for the slightly more complicated code
254+ // 0.23 == 0 ( Reason for the slightly more complicated code)
256255 const leftSideDigits = Math .max (Math .floor (value ).toString ().length , 0 ) * Math .sign (value );
257256
258257 const roundingPower = 10 ** Math .max (this .displayDecimalPlaces - leftSideDigits , 0 );
@@ -268,8 +267,7 @@ export default defineComponent({
268267 return ;
269268 }
270269
271- // We cannot use the clamp function here as we need undifined values to lead to no clamp.
272-
270+ // The simple `clamp()` function can't be used here since `undefined` values need to be boundless
273271 let sanitized = newValue ;
274272 if (typeof this .min === " number" ) sanitized = Math .max (sanitized , this .min );
275273 if (typeof this .max === " number" ) sanitized = Math .min (sanitized , this .max );
0 commit comments