parse-sel

1.0.0 • Public • Published

parse-sel

A "parse selector" kind of utility function.

Install

With npm do:

npm install parse-sel --save

Usage

This module exports a function that takes a string with a hyperscript selector and returns an object.

const parseSelector = require('parse-sel')
 
parseSelector('div#foo.bar')
// =>
// {
//   tagName: 'div',
//   id: 'foo',
//   className: 'bar'
// }
  

You can pass true as a second argument and get the tagName uppercase.

Credits

This is mainly lifted from the virtual-dom module. https://github.com/Matt-Esch/virtual-dom/blob/master/virtual-hyperscript/parse-tag.js

There's also quite a few packages like this on npm.

License

MIT

Package Sidebar

Install

npm i parse-sel

Weekly Downloads

602

Version

1.0.0

License

MIT

Last publish

Collaborators

  • acstll