Pull request Compare This branch is 220 commits ahead of subtleGradient:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.jshintrc dotfiles: .jshintrc, .gitignore, .npmignore Feb 14, 2014
.npmignore dotfiles: .jshintrc, .gitignore, .npmignore Feb 14, 2014
finder.js slick.match in :not pseudo Apr 28, 2015
index.js keep the same api for node & browser Jan 30, 2013
package.json 1.12.2 May 3, 2015


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.


  • 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"#foo > bar.baz") → [<bar>, <bar>, <bar>]"li > a", [<ol>, <ul>]) → [<a>, <a>, <a>]"#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.


  • 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?


  • node
  • node, String or SelectorObject

Returns: true or false

slick.matches(<div class=rocks>, "") → true
slick.matches(<div class=lame>, "") → 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?


  • 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


#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 }] }]