1.1.0 • Published 7 years ago

parse-element-selector v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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