This repository was archived by the owner on Sep 6, 2020. It is now read-only.
ruddzw/hassle
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
A learning implementation of a CSS selector engine. It will work in Firefox 3 and Safari so far, not sure about anything else.
Just call:
hassle("selector")
and you'll get back an array of matching elements!
You can also call hassle(element) to get an array containing that element, or hassle("selector", element) to only find elements in that element's subtree
Current selectors supported:
===Basics======
#id
Matches a single element with the given id attribute
element
Matches all elements with the given name
.class
Matches all elements with the given class
.class1.class2
Matches all elements with all the given classes
*
Matches all elements
selector1, selector2, selectorN
Matches the combined results of all the specified selectors
===Hierarchy======
ancestor descendant
Matches all descendant elements specified by "descendant" of elements specified by "ancestor"
parent > child
Matches all child elements specified by "child" of elements specified by "parent"
===Attribute Filters======
[attribute]
Matches elements that have the specified attribute
[attribute=value]
Matches elements that have the specified attribute with a certain value
[attribute!=value]
Matches elements that either don't have the specified attribute or do have the specified attribute but not with a certain value
[attribute^=value]
Matches elements that have the specified attribute and it starts with a certain value
[attribute$=value]
Matches elements that have the specified attribute and it ends with a certain value
[attribute*=value]
Matches elements that have the specified attribute and it contains a certain value
[attributeFilter1][attributeFilter2][attributeFilterN]
Matches elements that match all of the specified attribute filters