Add entry to coverage saying this selector was matched
976347
def record_coverage(self, rule):
        """"""
        log(DEBUG, u'Rule ({}): {}'.format(*rule).encode('utf-8'))
        self.coverage_lines.append('DA:{},1'.format(rule[0]))
20380
function (selector, done) {
  this.evaluate_now((selector) => {
    let element = document.querySelector(selector)
    if (!element) {
      return false
    }

    for (let key in element) {
      if (key.startsWith('__reactInternalInstance$')) {
        return true
      }
    }

    return false
  }, done, selector)
}
1297453
function matches(elem, selector) {
  // Vendor-specific implementations of `Element.prototype.matches()`.
  var proto = window.Element.prototype;
  var nativeMatches = proto.matches ||
      proto.mozMatchesSelector ||
      proto.msMatchesSelector ||
      proto.oMatchesSelector ||
      proto.webkitMatchesSelector;

  if (!elem || elem.nodeType !== 1) {
    return false;
  }

  var parentElem = elem.parentNode;

  // use native 'matches'
  if (nativeMatches) {
    return nativeMatches.call(elem, selector);
  }

  // native support for `matches` is missing and a fallback is required
  var nodes = parentElem.querySelectorAll(selector);
  var len = nodes.length;

  for (var i = 0; i < len; i++) {
    if (nodes[i] === elem) {
      return true;
    }
  }

  return false;
}
508043
function addSelector(prefix, selector) {
        if (selector !== undefined) {
            selectors[prefix] = selector;
        }
        return selectors[prefix];
    }
617556
private function doAddMatchers()
    {
        if (!empty($this->newMatchers)) {
            $this->shell->addMatchers($this->newMatchers);
            $this->newMatchers = [];
        }
    }
1242811
function (coverage /*, testName */) {
        var store = this.store;
        Object.keys(coverage).forEach(function (key) {
            var fileCoverage = coverage[key];
            if (store.hasKey(key)) {
                store.setObject(key, utils.mergeFileCoverage(fileCoverage, store.getObject(key)));
            } else {
                store.setObject(key, fileCoverage);
            }
        });
    }
690463
def match_subselectors(self, el, selectors):
        """"""

        match = True
        for sel in selectors:
            if not self.match_selectors(el, sel):
                match = False
        return match
658315
def _add_match(self, match_key, match_value, match):
        """"""
        if match_key is None:
            raise NullArgument()
        if match is None:
            match = True
        if match:
            inin = '$in'
        else:
            inin = '$nin'
        if match_key in self._query_terms:
            if inin in self._query_terms[match_key]:
                self._query_terms[match_key][inin].append(match_value)
            else:
                self._query_terms[match_key][inin] = [match_value]
        else:
            self._query_terms[match_key] = {inin: [match_value]}
985227
function(selector) {
        var token = {},     // one token per simple selector (left selector holds combinator)
            tokens = [],    // array of tokens
            id,             // unique id for the simple selector (if found)
            found = false,  // whether or not any matches were found this pass
            patterns = Y.Selector._patterns,
            match;          // the regex match

        selector = Y.Selector._replaceShorthand(selector); // convert ID and CLASS shortcuts to attributes

        /*
            Search for selector patterns, store, and strip them from the selector string
            until no patterns match (invalid selector) or we run out of chars.

            Multiple attributes and pseudos are allowed, in any order.
            for example:
                'form:first-child[type=button]:not(button)[lang|=en]'
        */
        do {
            found = false; // reset after full pass
            for (var re in patterns) {
                if (YAHOO.lang.hasOwnProperty(patterns, re)) {
                    if (re != 'tag' && re != 'combinator') { // only one allowed
                        token[re] = token[re] || [];
                    }
                    if ( (match = patterns[re].exec(selector)) ) { // note assignment
                        found = true;
                        if (re != 'tag' && re != 'combinator') { // only one allowed
                            // capture ID for fast path to element
                            if (re === 'attributes' && match[1] === 'id') {
                                token.id = match[3];
                            }

                            token[re].push(match.slice(1));
                        } else { // single selector (tag, combinator)
                            token[re] = match[1];
                        }
                        selector = selector.replace(match[0], ''); // strip current match from selector
                        if (re === 'combinator' || !selector.length) { // next token or done
                            token.attributes = Y.Selector._fixAttributes(token.attributes);
                            token.pseudos = token.pseudos || [];
                            token.tag = token.tag ? token.tag.toUpperCase() : '*';
                            tokens.push(token);

                            token = { // prep next token
                                previous: token
                            };
                        }
                    }
                }
            }
        } while (found);

        return tokens;
    }
753675
def _match_display_text(self, element_key, string, string_match_type, match):
        """"""
        if string is None or string_match_type is None:
            raise NullArgument()
        match_value = self._get_string_match_value(string, string_match_type)
        self._add_match(element_key + '.text', match_value, match)
490570
function shouldMatchElement(el) {
	if (!el) {
		return true;
	}
	if (el.getAttribute('aria-hidden') === 'true') {
		return false;
	}
	return shouldMatchElement(getComposedParent(el));
}
587729
def coverage(reportdir=None, extra=None):
    """"""

    import coverage as coverage_api
    cov = coverage_api.coverage()
    opts = {'directory': reportdir} if reportdir else {}

    cov.start()
    test(extra)
    cov.stop()
    cov.html_report(**opts)
1142369
function suiteComplete(result) {
		if (result.coverage) {
			coverageCollector.addCoverage(result.coverage);
		}

		// Have all suites completed?
		let completedSuites = suitesWithState('complete');
		if(Object.keys(completedSuites).length < Object.keys(suites).length) {
			return;
		}
		// All suites have completed, send the “complete” message to karma
		if(isDebug) {
			let [total, finished] = countTests();
			console.debug(`All ${Object.keys(suites).length} suites have completed, ran ${finished} of ${total} tests`);
		}
		if (result.coverage) {
			result.coverage = coverageCollector.getFinalCoverage();
		}
		karma.complete(result);
	}
1367654
function (
    elementMatcher, options) {
  options = options || {};
  return function (branches) {
    var expanded = branches;
    if (!options.dontExpandLeafArrays) {
      expanded = expandArraysInBranches(
        branches, options.dontIncludeLeafArrays);
    }
    var ret = {};
    ret.result = _.any(expanded, function (element) {
      var matched = elementMatcher(element.value);

      // Special case for $elemMatch: it means "true, and use this as an array
      // index if I didn't already have one".
      if (typeof matched === 'number') {
        // XXX This code dates from when we only stored a single array index
        // (for the outermost array). Should we be also including deeper array
        // indices from the $elemMatch match?
        if (!element.arrayIndices)
          element.arrayIndices = [matched];
        matched = true;
      }

      // If some element matched, and it's tagged with array indices, include
      // those indices in our result object.
      if (matched && element.arrayIndices)
        ret.arrayIndices = element.arrayIndices;

      return matched;
    });
    return ret;
  };
}
1355770
def add_match(mr, &slot)
      # check this is a signal.
      mrs = mr.to_s
      DBus.logger.debug "#{@signal_matchrules.size} rules, adding #{mrs.inspect}"
      # don't ask for the same match if we override it
      unless @signal_matchrules.key?(mrs)
        DBus.logger.debug "Asked for a new match"
        proxy.AddMatch(mrs)
      end
      @signal_matchrules[mrs] = slot
    end
770978
function getClosest(elem, selector) {
        while (elem !== document.body) {
            elem = elem.parentElement;
            var matches = typeof elem.matches == 'function' ? elem.matches(selector) : elem.msMatchesSelector(selector);

            if (matches) return elem;
        }
    }
142064
def addStartTag(contents, startTag):
    '''
        
    '''

    matchObj = DOCTYPE_MATCH.match(contents)
    if matchObj:
        idx = matchObj.end()
    else:
        idx = 0
    return "%s\n%s\n%s" %(contents[:idx], startTag, contents[idx:])