Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Adds a missing "var" keyword to updateMarkers
Browse files Browse the repository at this point in the history
The author forgot "var", so the "l" var is declared on the global scope. Apart from being wrong, it's dangerous for anyone using compiled/obfuscated JS, where it may be overwriting an obfuscated variable (common because it's only a single letter). I came across the bug when I noticed it overwriting what was supposed to be an alias for the window object in my compiled code.

Simply adding a var keyword redeclares it in the local scope, fixing the problem.
  • Loading branch information
0x24a537r9 committed Nov 19, 2014
1 parent 906be7a commit 033a39a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion paper-slider.html
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@
},

updateMarkers: function() {
this.markers = [], l = (this.max - this.min) / this.step;
this.markers = [];
var l = (this.max - this.min) / this.step;
if (!this.snaps && l > this.maxMarkers) {
return;
}
Expand Down

0 comments on commit 033a39a

Please sign in to comment.