# slick

> Standalone CSS Selector Finder and Parser.

Latest version **1.12.2** (published 2015-05-03) · MIT (http://mootools.net/license.txt) license · 0 weekly downloads

## Install

```sh
npm install slick
pnpm add slick
yarn add slick
bun add slick
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.12.2 |
| Published | 2015-05-03 |
| First published | 2012-04-03 |
| Weekly downloads | 0 |
| License | MIT (http://mootools.net/license.txt) |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Valerio Proietti |
| Maintainers | coolaj86, kamicane, arian |
| Keywords | dom, css, selector, finder, parser |

## Links

- npm: https://www.npmjs.com/package/slick
- Repository: https://github.com/kamicane/slick
- Issues: https://github.com/kamicane/slick/issues
- npm.io page: https://npm.io/package/slick

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.12.2 (latest) — 2015-05-03
- 1.12.1 — 2014-06-09
- 1.12.0 — 2014-06-08
- 1.11.2 — 2014-04-25
- 1.11.1 — 2014-04-24
- 1.11.0 — 2014-02-14
- 1.10.4 — 2013-12-03
- 1.10.3 — 2013-08-20
- 1.10.2 — 2013-08-02
- 1.10.1 — 2013-07-08
- 1.10.0 — 2013-01-23
- 1.9.2 — 2012-12-06
- 1.9.1-alpha — 2012-04-06
- 1.9.0-alpha — 2012-04-03
- 1.0.0 — 2012-04-03

## README

# Slick

Slick is a standalone selector engine that is totally slick.
Slick is split in 2 components: the Finder and the Parser. The Finder's job is to find nodes on a webpage, the Parser's job is to create a javascript object representation of any css selector.

Slick allows you to:

 * Create your own custom pseudo-classes
 * Use the Parser by itself.
 * Find nodes in XML documents.

 ---

## The Finder

Find nodes in the DOM

### `search` context for selector

Search this context for any nodes that match this selector.

Expects:
* selector: String or SelectorObject
* (**optional**) context: document or node or array of documents or nodes
* (**optional**) append: Array or Object with a push method

Returns: append argument or Array of 0 or more nodes

	slick.search("#foo > bar.baz") → [<bar>, <bar>, <bar>]
	slick.search("li > a", [<ol>, <ul>]) → [<a>, <a>, <a>]
	slick.search("#foo > bar.baz", document, []) → [<bar>, <bar>, <bar>]

### `find` first in context with selector or null

Find the first node in document that matches selector or null if none are found.

Expects:
* selector: String or SelectorObject
* (**optional**) context: document or node or array of documents or nodes

Returns: Element or null

	slick.find("#foo > bar.baz") → <bar>
	slick.find("#does-not-exist", node) → null

### node `matches` selector?

Does this node match this selector?

Expects:
* node
* node, String or SelectorObject

Returns: true or false

	slick.matches(<div class=rocks>, "div.rocks") → true
	slick.matches(<div class=lame>, "div.rocks") → false
	slick.matches(<div class=lame>, <div class=rocks>) → false

### context `contains` node?

Does this context contain this node? Is the context a parent of this node?

Expects:
* context: document or node
* node: node

Returns: true or false

	slick.contains(<ul>, <li>) → true
	slick.contains(<body>, <html>) → false

---

## The Parser

Parse a CSS selector string into a JavaScript object

### `parse` selector into object

Parse a CSS Selector String into a Selector Object.

Expects: String

Returns: SelectorObject

	slick.parse("#foo > bar.baz") → SelectorObject


### format

### `#foo > bar.baz`

	[[
		{ "combinator":" ", "tag":"*", "id":"foo" },
		{ "combinator":">", "tag":"bar", "classList": ["baz"], "classes": [{"value":"baz", "match": RegExp }]}
	]]

### `h1, h2, ul > li, .things`

	[
		[{ "combinator":" ", "tag": "h1" }],
		[{ "combinator":" ", "tag": "h2" }],
		[{ "combinator":" ", "tag": "ul" }, { "combinator": ">", "tag": "li" }],
		[{ "combinator":" ", "tag": "*", "classList": ["things"], "classes": [{"value": "things", "match": RegExp }] }]
	]

---
_Source: https://npm.io/package/slick · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
