Skip to content

Commit

Permalink
Fix for Issue remy#43 (and associated problems)
Browse files Browse the repository at this point in the history
Contains() should use pre-computed internal list of individual classes, rather than element's className, to avoid greedy false-positives.
  • Loading branch information
bobbykjack authored Nov 9, 2016
1 parent afeef96 commit 2d86e64
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions classList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ if (typeof window.Element === "undefined" || "classList" in document.documentEle
var prototype = Array.prototype,
push = prototype.push,
splice = prototype.splice,
join = prototype.join;
join = prototype.join,
indexOf = prototype.indexOf;

function DOMTokenList(el) {
this.el = el;
Expand All @@ -24,7 +25,7 @@ DOMTokenList.prototype = {
this.el.className = this.toString();
},
contains: function(token) {
return this.el.className.indexOf(token) != -1;
return indexOf.call(this, token) != -1;
},
item: function(index) {
return this[index] || null;
Expand Down

0 comments on commit 2d86e64

Please sign in to comment.