classlist-multiple-values
v2.0.0
Published
Use multiple values for `classList.add` and `classList.remove` methods.
Maintainers
Readme
classlist-multiple-values
Use multiple values for classList.add and classList.remove methods.
Install
npm install classlist-multiple-values --saveUsage
import multipleValues from 'classlist-multiple-values';
const element = document.querySelector('.jackie');
const cl = multipleValues(element.classList);
cl.add('henry winnie');
cl.add(['scooter', 'emma']);
cl.remove('henry winnie');
cl.remove(['scooter', 'emma']);API
multipleValues(classList)
Returns: object
Returns improved add and remove methods.
classList
Type: DOMTokenList
DOMTokenList which must contain add and remove methods.
multipleValues.add(values)
values
Type: string[]|string
Array of strings or space-separated string of class values to add to the element.
multipleValues.remove(values)
values
Type: string[]|string
Array of strings or space-separated string of class values to remove from the element.
Browser support
Tested in Chrome 80, Edge 80, Firefox 72 and should work in all modern browsers (support based on Browserslist configuration).
Test
For automated tests, run npm run test:automated (append :watch for watcher support).
License
MIT © Ivan Nikolić
