hast-util-class-list
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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

/hast-util-class-list/

    Package Sidebar

    Install

    npm i hast-util-class-list

    Weekly Downloads

    34

    Version

    2.0.0

    License

    Apache-2.0

    Unpacked Size

    9.1 kB

    Total Files

    7

    Last publish

    Collaborators

    • savelbr