Skip to content

Instantly share code, notes, and snippets.

View twiss's full-sized avatar

Daniel Huigens twiss

View GitHub Profile
@twiss
twiss / slick-any.js
Created July 12, 2011 11:46
Defines :any(selector)
/* :any(selector)
* requires Slick
* originally implemented by Firefox as :-moz-any()
* also supported by webkit as :webkit-any()
* example:
* :any(p, section) :any(pre, code) -- selects a pre or code tag in a p or section
* p pre, p code, section pre, section code -- same, but longer and less readable
*/
Slick.definePseudo('any', function(arg) {
@twiss
twiss / slick-has-n-children.js
Created July 11, 2011 18:51
Tries to define :has-n-children([<|>|<=|>=]n)
/* :has-n-children([<|>|<=|>=]n)
* requires Slick
* selects elements with (less/more than (or equal to)) n elements as children
* doesn't work yet (tested with 1.1.5)
*/
Slick.definePseudo('has-n-children', function(arg) {
var childrenLen = Slick.search(this, '> *').length;
var parsedArg = arg.match(/(<|>|<=|>=)?(\d+)/);
switch(parsedArg[1]) {