0.0.1 • Published 7 years ago
cssxpath-convertor v0.0.1
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)
0.0.1
7 years ago