Skip to content

This is yet another CSS selector. It's designed to be used by JSSoup, but it can also be used in other projects.

Notifications You must be signed in to change notification settings

chishui/JSSoupSelector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

unit-tests npm version NPM

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)

About

This is yet another CSS selector. It's designed to be used by JSSoup, but it can also be used in other projects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published