selector queries
557722
function selectorQuerySpy(results, selector) {
        var context = phantomas.getDOMPath(this);

        phantomas.incrMetric('DOMqueriesByQuerySelectorAll');
        phantomas.addOffender('DOMqueriesByQuerySelectorAll', {selector, node: context});
        querySpy('selector', selector, 'querySelectorAll', context, (results === null || results.length === 0));
    }
919360
function (selector) {
        var result = [];

        if (selector instanceof DomQuery) {
          selector = selector[0];
        }

        this.each(function (i, node) {
          while (node) {
            if (typeof selector == 'string' && DomQuery(node).is(selector)) {
              result.push(node);
              break;
            } else if (node == selector) {
              result.push(node);
              break;
            }

            node = node.parentNode;
          }
        });

        return DomQuery(result);
      }
1062933
def selector_matches?(selector)
      selector.any? do |group|
        group.keys.all? do |key|
          input_has_key?(key) && (@input[key] == group[key] || group[key].nil?)
        end
      end
    end
399804
function(selector) {
        var el = this.el.querySelector(selector);
        if (el && el.parentElement !== this.el) {
            el = null;
        }
        return el;
    }
1064331
def iselect(self, tag, limit=0):
        """"""

        for el in CSSMatch(self.selectors, tag, self.namespaces, self.flags).select(limit):
            yield el
687223
function ( selector ) {
            var node = this.element().previousSibling;
            if ( !node ) return;
    
            //comment, text
            if ( node.nodeType == 8 || node.nodeType == 3 && !$B.string.trim(node.data) ) {
                return $B( node ).prev( selector );
            } else {
                if ( typeof selector === 'string' ) node = $B.selector.match( node, selector )? node : undefined;
                return node;
            }
        }
1109793
function (selector, context) {
    if (typeof selector === 'string') {
      if (context) {
        var cont;
        if (context.jquery) {
          cont = context[0];
          if (!cont) {
            return context;
          }
        } else {
          cont = context;
        }
        return $(cont.querySelectorAll(selector));
      }

      return $(document.querySelectorAll(selector));
    }

    return $(selector, context);
  }
1019874
def submit_by_selector(self, selector):
    """"""
    elem = find_element_by_jquery(world.browser, selector)
    elem.submit()
442480
function filter(selector) {
  var arr = [], $ = this.air;
  this.each(function(el) {
    var selections;
    if(typeof selector === 'function') {
      if(selector.call(el)) {
        arr.push(el);
      }
    }else{
      selections = $(selector);
      if(~selections.dom.indexOf(el)) {
        arr.push(el);
      }
    }
  });
  return $(arr);
}
361046
function selector(a){
	a=a.match(/^(\W)?(.*)/);var b=document["getElement"+(a[1]?a[1]=="#"?"ById":"sByClassName":"sByTagName")](a[2]);
	var ret=[];	b!==null&&(b.length?ret=b:b.length===0?ret=b:ret=[b]);	return ret;
}
1039157
function( query, elements ){
        if( query != null ){
          var matches = false;
          elements = elements(); // make elements functional so we save cycles if query == null

          // query must match for at least one element (may be recursive)
          for(var i = 0; i < elements.size(); i++){
            if( queryMatches( query, elements.eq(i) ) ){
              matches = true;
              break;
            }
          }

          return matches;
        } else {
          return true;
        }
      }
496348
function (selector) {
        if (typeof selector == 'function') {
          return DomQuery(grep(this.toArray(), function (item, i) {
            return selector(i, item);
          }));
        }

        return DomQuery(DomQuery.filter(selector, this.toArray()));
      }
1313878
function select(selector) {
    var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;

    var selection = root.querySelectorAll(selector);

    return selection.length ? selection : null;
}
622012
function parse_selector(selector, contextmodels){

  var main_query = [];

  if(!selector){
    return [];
  }


  if(selector.diggerid){
    main_query.push({
      field:'_digger.diggerid',
      operator:'=',
      value:selector.diggerid
    })
  }
  /*
  
    we are finding the context itself not beneath it
    
  */
  else if(selector.tag==='self'){

    var ors = _.map(contextmodels, function(model){
      return {
        field:'_digger.diggerid',
        operator:'=',
        value:model.diggerid
      }
    })

    if(ors.length<=0){

    }
    else if(ors.length==1){
      main_query.push(ors[0]);
    }
    else{
      main_query.push({
        '$or':ors
      })
    }
    

  }
  else{
    // this is for a thing like:
    //    > folder.red product
    // i.e. folders on the root
    if(selector.splitter=='>' && (!contextmodels || contextmodels.length<=0)){
      main_query.push({
        field:'_digger.diggerparentid',
        operator:'=',
        value:null
      })
    }

    if(selector.tag==='*'){
      main_query.push({
        field:'_digger',
        operator:'exists'
      })
    }
    else {
      if(selector.tag){
        main_query.push({
          field:'_digger.tag',
          operator:'=',
          value:selector.tag
        })
      }

      if(selector.id){
        main_query.push({
          field:'_digger.id',
          operator:'=',
          value:selector.id
        })
      }

      if(_.keys(selector.class).length>0){

        _.each(_.keys(selector.class), function(classname){

          main_query.push({
            field:'_digger.class',
            operator:'=',
            value:classname
          })
          
        })
      }

      if(selector.attr){
        _.each(selector.attr, function(attr){
          
          var operator = attr.operator;
          var value = attr.value;

          if(_.isEmpty(attr.operator)){
            attr.operator = 'exists';
          }
          
          main_query.push(attr);
        })
      }
    }
  }

  return main_query;
}
467766
function (selector) {
        var match = this.match;

        function compileNameFilter(name) {
          if (name) {
            name = name.toLowerCase();

            return function (item) {
              return name === '*' || item.type === name;
            };
          }
        }

        function compileIdFilter(id) {
          if (id) {
            return function (item) {
              return item._name === id;
            };
          }
        }

        function compileClassesFilter(classes) {
          if (classes) {
            classes = classes.split('.');

            return function (item) {
              var i = classes.length;

              while (i--) {
                if (!item.classes.contains(classes[i])) {
                  return false;
                }
              }

              return true;
            };
          }
        }

        function compileAttrFilter(name, cmp, check) {
          if (name) {
            return function (item) {
              var value = item[name] ? item[name]() : '';

              return !cmp ? !!check :
                cmp === "=" ? value === check :
                  cmp === "*=" ? value.indexOf(check) >= 0 :
                    cmp === "~=" ? (" " + value + " ").indexOf(" " + check + " ") >= 0 :
                      cmp === "!=" ? value != check :
                        cmp === "^=" ? value.indexOf(check) === 0 :
                          cmp === "$=" ? value.substr(value.length - check.length) === check :
                            false;
            };
          }
        }

        function compilePsuedoFilter(name) {
          var notSelectors;

          if (name) {
            name = /(?:not\((.+)\))|(.+)/i.exec(name);

            if (!name[1]) {
              name = name[2];

              return function (item, index, length) {
                return name === 'first' ? index === 0 :
                  name === 'last' ? index === length - 1 :
                    name === 'even' ? index % 2 === 0 :
                      name === 'odd' ? index % 2 === 1 :
                        item[name] ? item[name]() :
                          false;
              };
            }

            // Compile not expression
            notSelectors = parseChunks(name[1], []);

            return function (item) {
              return !match(item, notSelectors);
            };
          }
        }

        function compile(selector, filters, direct) {
          var parts;

          function add(filter) {
            if (filter) {
              filters.push(filter);
            }
          }

          // Parse expression into parts
          parts = expression.exec(selector.replace(whiteSpace, ''));

          add(compileNameFilter(parts[1]));
          add(compileIdFilter(parts[2]));
          add(compileClassesFilter(parts[3]));
          add(compileAttrFilter(parts[4], parts[5], parts[6]));
          add(compilePsuedoFilter(parts[7]));

          // Mark the filter with pseudo for performance
          filters.pseudo = !!parts[7];
          filters.direct = direct;

          return filters;
        }

        // Parser logic based on Sizzle by John Resig
        function parseChunks(selector, selectors) {
          var parts = [], extra, matches, i;

          do {
            chunker.exec("");
            matches = chunker.exec(selector);

            if (matches) {
              selector = matches[3];
              parts.push(matches[1]);

              if (matches[2]) {
                extra = matches[3];
                break;
              }
            }
          } while (matches);

          if (extra) {
            parseChunks(extra, selectors);
          }

          selector = [];
          for (i = 0; i < parts.length; i++) {
            if (parts[i] != '>') {
              selector.push(compile(parts[i], [], parts[i - 1] === '>'));
            }
          }

          selectors.push(selector);

          return selectors;
        }

        this._selectors = parseChunks(selector, []);
      }
1169104
function select(rule, prefix) {
 return rule.selectors && rule.selectors[0] && rule.selectors[0].indexOf(prefix) === 0;
}
346646
function(selector, node) {
        var groups = selector.split(','),
            queries = [],
            prefix = '',
            i, len;

        if (node) {
            // enforce for element scoping
            if (node.tagName) {
                node.id = node.id || Y.guid();
                prefix = '[id="' + node.id + '"] ';
            }

            for (i = 0, len = groups.length; i < len; ++i) {
                selector =  prefix + groups[i];
                queries.push([selector, node]);
            }
        }

        return queries;
    }