Skip to content

Commit

Permalink
guard against parameters being set to NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshuebner committed Apr 10, 2011
1 parent d260c7c commit 9c9485b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions js/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ var Control = generateClass({

setState: function(value) {
value = Math.max(0, Math.min(this.getStateCount() - 1, value));
var changed = this._state != value;
this._state = value;
this.draw();
if (this._initialized && changed) this._triggerOnChange();
if (!isNaN(value)) {
var changed = this._state != value;
console.log('changed', changed, 'this._state', this._state, 'value', value);
this._state = value;
this.draw();
if (this._initialized && changed) this._triggerOnChange();
}
},

getState: function() {
Expand Down

0 comments on commit 9c9485b

Please sign in to comment.