Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including parse-element-selector with all npm packages installed. Try it out:

var parseElementSelector = require("parse-element-selector")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

parse-element-selector v1.1.0

parse string w3 element selector used in hyperscript functions


parse string w3 element selector used in hyperscript functions



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=]') // {tag:'circle', xmlns: ''}


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('') => {})


Released under the MIT License


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free