_sel returns an array of simple selector fragment objects from the passed complex selector string
519142
function _sel(selector)
    {
        var f, out = [];
        if (typeof selector == "string")
        {
            while (selector != "")
            {
                f = selector.match(re_selector_fragment);
                if (f[0] == "") return null;
                out.push({ rel: f[1], tag: f[2], uTag: (f[2] || "").toUpperCase(), id: f[3], classes: (f[4]) ? f[4].split(".") : _undefined });
                selector = selector.substring(f[0].length);
            }
        }
        return out;
    }
1204082
function(sel) {
  var filter = []
    , comb = combinators.noop
    , qname
    , cap
    , op
    , len;

  // add implicit universal selectors
  sel = sel.replace(/(^|\s)(:|\[|\.|#)/g, '$1*$2');

  while (cap = /\s*((?:\w+|\*)(?:[.#:][^\s]+|\[[^\]]+\])*)\s*$/.exec(sel)) {
    len = sel.length - cap[0].length;
    cap = cap[1].split(/(?=[\[:.#])/);
    if (!qname) qname = cap[0];
    filter.push(comb(parse(cap)));
    if (len) {
      op = sel[len - 1];
      // if the combinator doesn't exist, 
      // assume it was a whitespace.
      comb = combinators[op] || combinators[op = ' '];
      sel = sel.substring(0, op !== ' ' ? --len : len);
    } else {
      break;
    }
  }

  // compile to a single function
  filter = make(filter);

  // optimize the first qname
  filter.qname = qname;

  return filter;
}
125000
function querySelectorAlls(str) {
        return (document.querySelectorAll || window.jQuery || window.Zepto || selector).call(document, str);
    }
1083275
function _qwery(selector, _root) {
      var r = [], ret = [], i, l, m, token, tag, els, intr, item, root = _root
        , tokens = tokenCache.g(selector) || tokenCache.s(selector, selector.split(tokenizr))
        , dividedTokens = selector.match(dividers)
  
      if (!tokens.length) return r
  
      token = (tokens = tokens.slice(0)).pop() // copy cached tokens, take the last one
      if (tokens.length && (m = tokens[tokens.length - 1].match(idOnly))) root = byId(_root, m[1])
      if (!root) return r
  
      intr = q(token)
      // collect base candidates to filter
      els = root !== _root && root.nodeType !== 9 && dividedTokens && /^[+~]$/.test(dividedTokens[dividedTokens.length - 1]) ?
        function (r) {
          while (root = root.nextSibling) {
            root.nodeType == 1 && (intr[1] ? intr[1] == root.tagName.toLowerCase() : 1) && (r[r.length] = root)
          }
          return r
        }([]) :
        root[byTag](intr[1] || '*')
      // filter elements according to the right-most part of the selector
      for (i = 0, l = els.length; i < l; i++) {
        if (item = interpret.apply(els[i], intr)) r[r.length] = item
      }
      if (!tokens.length) return r
  
      // filter further according to the rest of the selector (the left side)
      each(r, function(e) { if (ancestorMatch(e, tokens, dividedTokens)) ret[ret.length] = e })
      return ret
    }
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;
}
171831
function transformSelector(selector, customSelectors) {
	const transpiledSelectors = [];

	for (const index in selector.nodes) {
		const { value, nodes } = selector.nodes[index];

		if (value in customSelectors) {
			for (const replacementSelector of customSelectors[value].nodes) {
				const selectorClone = selector.clone();

				selectorClone.nodes.splice(index, 1, ...replacementSelector.clone().nodes.map(node => {
					// use spacing from the current usage
					node.spaces = { ...selector.nodes[index].spaces };

					return node;
				}));

				const retranspiledSelectors = transformSelector(selectorClone, customSelectors);

				adjustNodesBySelectorEnds(selectorClone.nodes, Number(index));

				if (retranspiledSelectors.length) {
					transpiledSelectors.push(...retranspiledSelectors);
				} else {
					transpiledSelectors.push(selectorClone);
				}
			}

			return transpiledSelectors;
		} else if (nodes && nodes.length) {
			transformSelectorList(selector.nodes[index], customSelectors);
		}
	}

	return transpiledSelectors;
}
817407
def _elements(cls):
        '''    '''
        if not cls.__is_selector():
            raise Exception("Invalid selector[%s]." %cls.__control["by"])
        
        driver = Web.driver
        try:            
            elements = WebDriverWait(driver, cls.__control["timeout"]).until(lambda driver: getattr(driver,"find_elements")(cls.__control["by"], cls.__control["value"]))
        except:            
            raise Exception("Timeout at %d seconds.Element(%s) not found." %(cls.__control["timeout"],cls.__control["by"]))
            
        return elements
277988
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;
        }
822629
function dataselectfn(sel){
    if(typeof(sel) === 'function'){
      return sel;
    }
    //check for a valid js variable name with hyphen(for properties only), $, _ and :
    var m = sel.match(/^[a-zA-Z\$_\@][\w\$:-]*(\.[\w\$:-]*[^\.])*$/);
    if(m === null){
      var found = false, s = sel, parts = [], pfns = [], i = 0, retStr;
      // check if literal
      if(/\'|\"/.test( s.charAt(0) )){
        if(/\'|\"/.test( s.charAt(s.length-1) )){
          retStr = s.substring(1, s.length-1);
          return function(){ return retStr; };
        }
      }else{
        // check if literal + #{var}
        while((m = s.match(/#\{([^{}]+)\}/)) !== null){
          found = true;
          parts[i++] = s.slice(0, m.index);
          pfns[i] = dataselectfn(m[1]);
          s = s.slice(m.index + m[0].length, s.length);
        }
      }
      if(!found){
        error('bad data selector syntax: ' + sel);
      }
      parts[i] = s;
      return concatenator(parts, pfns);
    }
    m = sel.split('.');
    return function(ctxt){
      var data = ctxt.context;
      if(!data){
        return '';
      }
      var  v = ctxt[m[0]],
        i = 0;
      if(v && v.item){
        data = v.item;
        i += 1;
      }
      var n = m.length;
      for(; i < n; i++){
        if(!data){break;}
        data = data[m[i]];
      }
      return (!data && data !== 0) ? '':data;
    };
  }
1023988
def get_objects(ns, element_name, ext_class)
      elements = getlist(ns, element_name)
      return [] if elements.empty?
      elements.collect do |e|
        ext_class.new(:namespace => ns, :elem => e)
      end
    end
299345
def marking_selector_syntax(instance):
    
    if 'granular_markings' not in instance:
        return

    list_index_re = re.compile(r"\[(\d+)\]")
    for marking in instance['granular_markings']:
        if 'selectors' not in marking:
            continue

        selectors = marking['selectors']
        for selector in selectors:
            segments = selector.split('.')

            obj = instance
            prev_segmt = None
            for segmt in segments:
                index_match = list_index_re.match(segmt)
                if index_match:
                    try:
                        idx = int(index_match.group(1))
                        obj = obj[idx]
                    except IndexError:
                        yield JSONError("'%s' is not a valid selector because"
                                        " %s is not a valid index."
                                        % (selector, idx), instance['id'])
                    except KeyError:
                        yield JSONError("'%s' is not a valid selector because"
                                        " '%s' is not a list."
                                        % (selector, prev_segmt), instance['id'])
                else:
                    try:
                        obj = obj[segmt]
                    except KeyError as e:
                        yield JSONError("'%s' is not a valid selector because"
                                        " %s is not a property."
                                        % (selector, e), instance['id'])
                    except TypeError:
                        yield JSONError("'%s' is not a valid selector because"
                                        " '%s' is not a property."
                                        % (selector, segmt), instance['id'])
                prev_segmt = segmt
1148087
def first_simple_sel(rule)
      sseq = first_sseq(rule)
      return unless sseq.is_a?(Sass::Selector::SimpleSequence)
      sseq.members.first
    end
1126629
function(sel) {
      if (!this.length) {
        return this;
      }
      var matched = [],
    	 		el = this[0];

    	while (el = el.nextElementSibling) {
    		sel ?
    			(u(el).is(sel) && matched.push(el)) :
    			matched.push(el);
    	}
    	return u(matched);
    }
781864
def _filtered_list(self, selector):
        
        res = []
        for elem in self.obj:
            self._append(elem, selector, res)
        return res
835965
def get_members(self, selector):
        
        members = []
        for member in self.get_member_list():
            if selector.select(member):
                members.append(member)

        return members
676852
def parse_has_combinator(self, sel, m, has_selector, selectors, rel_type, index):
        """"""

        combinator = m.group('relation').strip()
        if not combinator:
            combinator = WS_COMBINATOR
        if combinator == COMMA_COMBINATOR:
            if not has_selector:
                # If we've not captured any selector parts, the comma is either at the beginning of the pattern
                # or following another comma, both of which are unexpected. Commas must split selectors.
                raise SelectorSyntaxError(
                    "The combinator '{}' at postion {}, must have a selector before it".format(combinator, index),
                    self.pattern,
                    index
                )
            sel.rel_type = rel_type
            selectors[-1].relations.append(sel)
            rel_type = ":" + WS_COMBINATOR
            selectors.append(_Selector())
        else:
            if has_selector:
                # End the current selector and associate the leading combinator with this selector.
                sel.rel_type = rel_type
                selectors[-1].relations.append(sel)
            elif rel_type[1:] != WS_COMBINATOR:
                # It's impossible to have two whitespace combinators after each other as the patterns
                # will gobble up trailing whitespace. It is also impossible to have a whitespace
                # combinator after any other kind for the same reason. But we could have
                # multiple non-whitespace combinators. So if the current combinator is not a whitespace,
                # then we've hit the multiple combinator case, so we should fail.
                raise SelectorSyntaxError(
                    'The multiple combinators at position {}'.format(index),
                    self.pattern,
                    index
                )
            # Set the leading combinator for the next selector.
            rel_type = ':' + combinator
        sel = _Selector()

        has_selector = False
        return has_selector, sel, rel_type
1089305
function find(n, sel){
    if(typeof n === 'string'){
      sel = n;
      n = false;
    }
    if(typeof document.querySelectorAll !== 'undefined'){
      return (n||document).querySelectorAll( sel );
    }else{
      error('You can test PURE standalone with: iPhone, FF3.5+, Safari4+ and IE8+\n\nTo run PURE on your browser, you need a JS library/framework with a CSS selector engine');
    }
  }