Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
/ classlist Public archive

Ponyfill to fix element.classList browser inconsistencies

License

Notifications You must be signed in to change notification settings

YR/classlist

Repository files navigation

NPM Version Build Status

Ponyfill to fix element.classList browser inconsistencies.

  • Fixes multiple arguments for add()/remove()
  • Adds missing force argument for toggle()
  • Shadows contains()/replace() for convenience.

Note: does not fix missing classList on SVG/MathML elements on some platforms.

Usage

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);

About

Ponyfill to fix element.classList browser inconsistencies

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •