Ponyfill to fix element.classList
browser inconsistencies.
- Fixes multiple arguments for
add()/remove()
- Adds missing
force
argument fortoggle()
- Shadows
contains()/replace()
for convenience.
Note: does not fix missing classList
on SVG/MathML elements on some platforms.
import { addClass, removeClass, toggleClass } from '@yr/classlist';
// Add/remove multiple classes
addClass(element, 'foo', 'bar');
removeClass(element, 'foo', 'bar');
// Respect 'force' argument
toggleClass(element, 'foo', Math.random() > 0.5);