0.0.1 • Published 7 years ago

cssxpath-convertor v0.0.1

Weekly downloads
4
License
BSD-3-Clause
Repository
github
Last release
7 years ago

cssxpath

Converts CSS3 selectors into XPath expression. Based on abandoned Firebug code.

Install

npm i cssxpath

Examples

const cssxpath = require('cssxpath');
cssxpath.convert('[attribute]')
/*
* Output: //*[@attribute]
*/

Or if you want to test different CSS selectors - you may input them in prompt using:

const cssxpath = require('cssxpath');
cssxpath.ask()
/*
* Run console interface and ask you to enter CSS selector
*/

You can see other supported examples in ./test/test.js

What is next

Support of those expressions will be added in next versions:

  • :not(selector)
  • :nth-child(n)
  • :nth-last-child(n)
  • nth-of-type(n)
  • nth-last-of-type(n)

Other pseudo selectors (e.g. :disabled) are also not supported. Selectors with position such as :nth-child(n) are trimmed out from input CSS in this version.

License

BSD 3-clause license (since it's based on Firefox code)