Simulate the browser's classList
API for hast
nodes.
npm install hast-util-class-list
var ClassList = require('hast-util-class-list')
var el = {type: 'element', tagName: 'div', properties: {className: ['one']}}
var classList = ClassList(el)
classList.contains('one') // => true
classList.toggle('one') // => false
// el: {type: 'element', tagName: 'div', properties: {className: []}}
classList.add('one')
// el: {type: 'element', tagName: 'div', properties: {className: ['one']}}
classList.replace('one', 'two')
// el: {type: 'element', tagName: 'div', properties: {className: ['two']}}
classList.remove('two')
// el: {type: 'element', tagName: 'div', properties: {className: []}}
This module was loosely based on class-list
by Raynos.
Apache-2.0