parse-element-selector

1.1.0 • Public • Published

parse-element-selector

parse string w3 element selector used in hyperscript functions

ExampleFeaturesAPILicense

Example

var parse = require('parse-element-selector')
 
var d01 = parse('div.c1#i1[style="color:blue"].c2'), // {tag:'div', attributes:{id:'i1', class:'c1 c2'}}
    d02 = parse('svg:circle'), // {tag:'circle', prefix:'svg'}
    d03 = parse('circle[xmlns=http://www.w3.org/2000/svg]') // {tag:'circle', xmlns: 'http://www.w3.org/2000/svg'}

API

Object returned is always in the form {tag, xmlns, prefix, attributes} so that tag, xmlns and/or prefix can be used for document.createElement or document.createElementNS before applying the remaining attributes if any. Properties not found are not declared (i.e. parse('') => {})

License

Released under the MIT License

Package Sidebar

Install

npm i parse-element-selector

Weekly Downloads

4

Version

1.1.0

License

MIT

Last publish

Collaborators

  • hugov