Last active
February 16, 2018 13:27
-
-
Save MaxArt2501/c070925a7437a8f8a42a7e724a2260ff to your computer and use it in GitHub Desktop.
Add second argument support in DOMTokeList.toggle (e.g. for Internet Explorer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(dtl) { | |
if (!dtl) return; | |
var elem = document.createElement("div"); | |
div.classList.toggle("test", false); | |
if (div.className === "test") | |
dtl.prototype.toggle = (function(toggle) { | |
return function(cls, force) { | |
if (typeof force === "boolean") | |
return this[force ? "add" : "remove"](cls); | |
return toggle.call(this, cls); | |
}; | |
})(dtl.prototype.toggle); | |
})(window.DOMTokenList); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var elem = [...]
should bevar div = [...]