JSPM

parse-sel

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2130
  • Score
    100M100P100Q124293F
  • License MIT

Parse hyperscript selector strings

Package Exports

  • parse-sel

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (parse-sel) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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