classList.js is a cross-browser JavaScript shim that fully implements `element.classList`. Refer to [the MDN page on `element.classList`][1] for more information.
if("document"inself&&!("classList"indocument.createElement("_")&&"classList"indocument.createElementNS("http://www.w3.org/2000/svg","svg"))){(function(j){"use strict";if(!("Element"inj)){return}vara="classList",f="prototype",m=j.Element[f],b=Object,k=String[f].trim||function(){returnthis.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){varp=0,o=this.length;for(;p<o;p++){if(pinthis&&this[p]===q){returnp}}return-1},n=function(o,p){this.name=o;this.code=DOMException[o];this.message=p},g=function(p,o){if(o===""){thrownewn("SYNTAX_ERR","An invalid or illegal string was specified")}if(/\s/.test(o)){thrownewn("INVALID_CHARACTER_ERR","String contains an invalid character")}returnc.call(p,o)},d=function(s){varr=k.call(s.getAttribute("class")),q=r?r.split(/\s+/):[],p=0,o=q.length;for(;p<o;p++){this.push(q[p])}this._updateClassName=function(){s.setAttribute("class",this.toString())}},e=d[f]=[],i=function(){returnnewd(this)};n[f]=Error[f];e.item=function(o){returnthis[o]||null};e.contains=function(o){o+="";returng(this,o)!==-1};e.add=function(){vars=arguments,r=0,p=s.length,q,o=false;do{q=s[r]+"";if(g(this,q)===-1){this.push(q);o=true}}while(++r<p);if(o){this._updateClassName()}};e.remove=function(){vart=arguments,s=0,p=t.length,r,o=false;do{r=t[s]+"";varq=g(this,r);if(q!==-1){this.splice(q,1);o=true}}while(++s<p);if(o){this._updateClassName()}};e.toggle=function(p,q){p+="";varo=this.contains(p),r=o?q!==true&&"remove":q!==false&&"add";if(r){this[r](p)}return!o};e.toString=function(){returnthis.join("")};if(b.defineProperty){varl={get:i,enumerable:true,configurable:true};try{b.defineProperty(m,a,l)}catch(h){if(h.number===-2146823252){l.enumerable=false;b.defineProperty(m,a,l)}}}else{if(b[f].__defineGetter__){m.__defineGetter__(a,i)}}}(self))};
if("document"inself){if(!("classList"indocument.createElement("_"))){(function(j){"use strict";if(!("Element"inj)){return}vara="classList",f="prototype",m=j.Element[f],b=Object,k=String[f].trim||function(){returnthis.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){varp=0,o=this.length;for(;p<o;p++){if(pinthis&&this[p]===q){returnp}}return-1},n=function(o,p){this.name=o;this.code=DOMException[o];this.message=p},g=function(p,o){if(o===""){thrownewn("SYNTAX_ERR","An invalid or illegal string was specified")}if(/\s/.test(o)){thrownewn("INVALID_CHARACTER_ERR","String contains an invalid character")}returnc.call(p,o)},d=function(s){varr=k.call(s.getAttribute("class")||""),q=r?r.split(/\s+/):[],p=0,o=q.length;for(;p<o;p++){this.push(q[p])}this._updateClassName=function(){s.setAttribute("class",this.toString())}},e=d[f]=[],i=function(){returnnewd(this)};n[f]=Error[f];e.item=function(o){returnthis[o]||null};e.contains=function(o){o+="";returng(this,o)!==-1};e.add=function(){vars=arguments,r=0,p=s.length,q,o=false;do{q=s[r]+"";if(g(this,q)===-1){this.push(q);o=true}}while(++r<p);if(o){this._updateClassName()}};e.remove=function(){vart=arguments,s=0,p=t.length,r,o=false,q;do{r=t[s]+"";q=g(this,r);while(q!==-1){this.splice(q,1);o=true;q=g(this,r)}}while(++s<p);if(o){this._updateClassName()}};e.toggle=function(p,q){p+="";varo=this.contains(p),r=o?q!==true&&"remove":q!==false&&"add";if(r){this[r](p)}if(q===true||q===false){returnq}else{return!o}};e.toString=function(){returnthis.join("")};if(b.defineProperty){varl={get:i,enumerable:true,configurable:true};try{b.defineProperty(m,a,l)}catch(h){if(h.number===-2146823252){l.enumerable=false;b.defineProperty(m,a,l)}}}else{if(b[f].__defineGetter__){m.__defineGetter__(a,i)}}}(self))}else{(function(){varb=document.createElement("_");b.classList.add("c1","c2");if(!b.classList.contains("c2")){varc=function(e){vard=DOMTokenList.prototype[e];DOMTokenList.prototype[e]=function(h){varg,f=arguments.length;for(g=0;g<f;g++){h=arguments[g];d.call(this,h)}}};c("add");c("remove")}b.classList.toggle("c3",false);if(b.classList.contains("c3")){vara=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(d,e){if(1inarguments&&!this.contains(d)===!e){returne}else{returna.call(this,d)}}}b=null}())}};