Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
New DOM4 classList polyfill for browsers with classList support
void function(global, tmp) {
if("classList" in tmp) {
void function(_add, _remove, _Array_forEach_) {
this["add"] = function() {, _add, this);
this["remove"] = function() {, _remove, this);
this["toggle"] = function(token, forse) {
var result = this.contains(token)
, method = result ?
forse !== true && "remove"
forse !== false && "add"
if(method) {
return result;
}.call((tmp = global["DOMTokenList"].prototype), tmp["add"], tmp["remove"], Array.prototype.forEach);
//else {
//Browser does't support classList -> use full DOMTokenList polyfill
}(window, document.createElement("b"));
void function(b,c){"classList"in c&&void function(h,i,a){this.add=function(){,h,this)};this.remove=function(){,i,this)};this.toggle=function(a,d){var e=this.contains(a),f=e?!0!==d&&"remove":!1!==d&&"add";if(f)this[f](a);return e}}.call(c=b.DOMTokenList.prototype,c.add,c.remove,Array.prototype.forEach);}(window,document.createElement("b"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.