eligrey/classList.js — pull request #28 by eanakashima (2014-07-24 01:57:56+00:00)
Title: Normalize add, remove, and toggle to support multiple arguments

This change would normalize `add`, `remove`, and `toggle` to always support multiple arguments in browsers with older classList implementations.

Currently, in browsers with older classList implementations like IE10/11 and Firefox <26, calling something like `myElement.classList.add("class1", "class2")` would only add the first token `"class1"` to the list. This shims `add`, `remove`, and `toggle` to match the current [spec](http://dom.spec.whatwg.org/#domtokenlist) behavior when called with multiple arguments. Updated behavior:
- `add(tokens…)` can add multiple tokens at once
- `remove(tokens…)` can remove multiple tokens at once
- `toggle(token[, force])` accepts an optional boolean argument that dictates whether to add/remove the token

If the browser supports multiple arguments already, this shouldn't override the native implementation.

This is similar to https://github.com/eligrey/classList.js/pull/6 in goal, just with a smaller diff. (H/T to @mislav for inspiration on the add/remove and toggle implementations.)