lib/zest.js
function(sel) {
  var cap, param;

  if (typeof sel !== 'string') {
    if (sel.length > 1) {
      var func = []
        , i = 0
        , l = sel.length;

      for (; i < l; i++) {
        func.push(parse(sel[i]));
      }

      l = func.length;
      return function(el) {
        for (i = 0; i < l; i++) {
          if (!func[i](el)) return;
        }
        return true;
      };
    }
    // optimization: shortcut
    return sel[0] === '*' 
      ? selectors['*'] 
      : selectors.type(sel[0]);
  }

  switch (sel[0]) {
    case '.': return selectors.attr('class', '~=', sel.substring(1));
    case '#': return selectors.attr('id', '=', sel.substring(1));
    case '[': cap = /^\[([\w-]+)(?:([^\w]?=)([^\]]+))?\]/.exec(sel);
              return selectors.attr(cap[1], cap[2] || '-', unquote(cap[3]));
    case ':': cap = /^(:[\w-]+)\(([^)]+)\)/.exec(sel);
              if (cap) sel = cap[1], param = unquote(cap[2]);
              return param ? selectors[sel](param) : selectors[sel];
    case '*': return selectors['*'];
    default:  return selectors.type(sel);
  }
}
function(sel) {
  var cap, param;

  if (typeof sel !== 'string') {
    if (sel.length > 1) {
      var func = []
        , i = 0
        , l = sel.length;

      for (; i < l; i++) {
        func.push(parse(sel[i]));
      }

      l = func.length;
      return function(el) {
        for (i = 0; i < l; i++) {
          if (!func[i](el)) return;
        }
        return true;
      };
    }
    // optimization: shortcut
    return sel[0] === '*' 
      ? selectors['*'] 
      : selectors.type(sel[0]);
  }

  switch (sel[0]) {
    case '.': return selectors.attr('class', '~=', sel.substring(1));
    case '#': return selectors.attr('id', '=', sel.substring(1));
    case '[': cap = /^\[([\w-]+)(?:([^\w]?=)([^\]]+))?\]/.exec(sel);
              return selectors.attr(cap[1], cap[2] || '-', unquote(cap[3]));
    case ':': cap = /^(:[\w-]+)\(([^)]+)\)/.exec(sel);
              if (cap) sel = cap[1], param = unquote(cap[2]);
              return param ? selectors[sel](param) : selectors[sel];
    case '*': return selectors['*'];
    default:  return selectors.type(sel);
  }
}
function ( sel ) { var cap , param ; if ( typeof sel !== 'string' ) { if ( sel . length > 1 ) { var func = [ ] , i = 0 , l = sel . length ; for ( ; i < l ; i ++ ) { func . push ( parse ( sel [ i ] ) ) ; } l = func . length ; return function ( el ) { for ( i = 0 ; i < l ; i ++ ) { if ( ! func [ i ] ( el ) ) return ; } return true ; } ; } // optimization: shortcut return sel [ 0 ] === '*' ? selectors [ '*' ] : selectors . type ( sel [ 0 ] ) ; } switch ( sel [ 0 ] ) { case '.' : return selectors . attr ( 'class' , '~=' , sel . substring ( 1 ) ) ; case '#' : return selectors . attr ( 'id' , '=' , sel . substring ( 1 ) ) ; case '[' : cap = / ^\[([\w-]+)(?:([^\w]?=)([^\]]+))?\] / . exec ( sel ) ; return selectors . attr ( cap [ 1 ] , cap [ 2 ] || '-' , unquote ( cap [ 3 ] ) ) ; case ':' : cap = / ^(:[\w-]+)\(([^)]+)\) / . exec ( sel ) ; if ( cap ) sel = cap [ 1 ] , param = unquote ( cap [ 2 ] ) ; return param ? selectors [ sel ] ( param ) : selectors [ sel ] ; case '*' : return selectors [ '*' ] ; default : return selectors . type ( sel ) ; } }
Parsing
 parse simple selectors, return a `test`
Parsing parse simple selectors return a test