parse-element-selector
v1.1.0
Published
parse string w3 element selector used in hyperscript functions
Downloads
8
Maintainers
Readme
parse-element-selector
parse string w3 element selector used in hyperscript functions
• Example • Features • API • License
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