1.0.0 • Published 8 years ago

parse-sel v1.0.0

Weekly downloads
584
License
MIT
Repository
github
Last release
8 years ago

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