Changeset 13729

Show
Ignore:
Timestamp:
05/13/08 11:59:20 (2 months ago)
Author:
doughays
Message:

Fixes #6398. If the value is not-a-number and the user requests spinning, then assign defaults based on min/max/0.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/form/NumberSpinner.js

    r12665 r13729  
    1515        adjust: function(/* Object */ val, /*Number*/ delta){ 
    1616                // summary: change Number val by the given amount 
     17                if(isNaN(val) && delta != 0){ // blank or invalid value and they want to spin, so create defaults 
     18                        var increasing = (delta > 0), 
     19                                gotMax = (typeof this.constraints.max == "number"), 
     20                                gotMin = (typeof this.constraints.min == "number"); 
     21                        val = increasing? (gotMin? this.constraints.min : (gotMax? this.constraints.max : 0)) : 
     22                                        (gotMax? this.constraints.max : (gotMin? this.constraints.min : 0)); 
     23                } 
    1724                var newval = val+delta; 
    1825                if(isNaN(val) || isNaN(newval)){ return val; }