diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/classList.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/classList.js b/lib/classList.js new file mode 100644 index 0000000..1bb626d --- /dev/null +++ b/lib/classList.js @@ -0,0 +1,3 @@ +// classList polyfill from https://github.com/remy/polyfills/blob/master/classList.js +(function(){function c(a){this._element=a;if(a.className!=this.classCache){this._classCache=a.className;var a=this._classCache.split(" "),b;for(b=0;b<a.length;b++)e.call(this,a[b])}}if(!("undefined"===typeof Element||Element.prototype.hasOwnProperty("classList"))){var d=[].indexOf,f=[].slice,e=[].push,g=[].splice,h=[].join;c.prototype={add:function(a){e.call(this,a);this._element.className=f.call(this,0).join(" ")},contains:function(a){return-1!==d.call(this,a)},item:function(a){return this[a]||null}, +remove:function(a){a=d.call(this,a);g.call(this,a,1);this._element.className=f.call(this,0).join(" ")},toString:function(){return h.call(this," ")},toggle:function(a){-1===d.call(this,a)?this.add(a):this.remove(a)}};window.DOMTokenList=c;Element.prototype.__defineGetter__("classList",function(){return new c(this)})}})();
\ No newline at end of file |