Skip to content

brechtcs/hast-util-class-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hast-util-class-list

Simulate the browser's classList API for hast nodes.

Installation

npm install hast-util-class-list

Usage

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: []}}

Acknowledgements

This module was loosely based on class-list by Raynos.

License

Apache-2.0

About

Simulate the browser's classList API for HAST nodes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published