Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add second argument support in DOMTokeList.toggle (e.g. for Internet Explorer)
(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, cls);

This comment has been minimized.

Copy link

frudolf commented Feb 16, 2018

var elem = [...] should be var div = [...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.