jssoup-selector
v0.0.1
Published
This is yet another javascript CSS selector library.
Downloads
63
Readme
JSSoupSelector
This is a simple CSS selector written in pure JavaScript code. It aims to provide CSS selector functions to JSSoup. But it can do more as it has flexibility to support other dom packages as well (e.g. jsdom).
Supported CSS Selectors
JSSoupSelector has implemented most basic selectors:
- Universal Selector
*
- Type Selector
div
- Class Selector
.class
- ID Selector
#id
- Attribute Selector
[title]
- Descendant Combinator
body div
- Child Combinator
body > div
- Next Sibling Combinator
body + div
- Subsequent Sibling Combinator
body ~ div
- Groups of Selectors
div.class, span#id, p[title]
Install
$ npm install jssoup-selector
usage
Import
//react-native
import SoupSelector from 'jssoup';
// nodejs
var SoupSelector = require('jssoup-selector').default;
select
JSSoupSelector requires a dom adaptor class as input so that it can adapt dom element access functions to dom package specific functions. Now it only supports JSSoup adapter.
var selector = new SoupSelector(new JSSoupAdapter());
var soup = new JSSoup(data);
var elements = selector.select("*", soup)