Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

css-xpath

1.0.0 • Public • Published

css-xpath

Build Status Known Vulnerabilities npm version

Single method library for converting CSS selectors to XPath queries. This forked out of the Potent Tools project, where we are playing archaeologist and recovering some useful but abandoned Firebug code.

Installation

yarn add css-xpath

Usage

const cssXPath = require('css-xpath');
cssXPath('html > body') // '//html/body'

That's the whole library. Take in a CSS selector, output an XPath query. To see some example outputs, consult the tests.

They're unexposed, but if you want, there's some regular expressions that might be interesting if you're trying to parse CSS yourself. They are not exposed,

Bugs

Please submit a pull request with a failing test or create an issue if you get unexpected results. Our current perspective is that any valid XPath query that has the same selector semantics is a correct result, but in general, we do produce and prefer simpler queries to unnecessarily complex ones.

License

As the code in this repository is derived from the Firebug source code, its BSD 3-clause license applies.

install

npm i css-xpath

Downloadsweekly downloads

297

version

1.0.0

license

BSD-3-Clause

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability