Compare the selectors and decide if we
need to inherit gap from compared selector or not.
@type {String} selA
@type {String} selB
@return {Boolean}
340627
function shouldInheritGap (selA, selB) {
  let result

  // get arrays of selector split in 3-deep array
  let splitSelectorArrA = splitSelector(selA)
  let splitSelectorArrB = splitSelector(selB)

  if (splitSelectorArrA[0].length < splitSelectorArrB[0].length) {
    // abort if selectorA has lower descendant specificity then selectorB
    // (e.g '.grid' and '.hello .world .grid')
    return false
  } else if (splitSelectorArrA[0].length > splitSelectorArrB[0].length) {
    // if selectorA has higher descendant specificity then selectorB
    // (e.g '.foo .bar .grid' and '.grid')

    let idx = splitSelectorArrA[0].reduce((res, [item], index) => {
      let firstSelectorPart = splitSelectorArrB[0][0][0]
      if (item === firstSelectorPart) {
        return index
      }
      return false
    }, false)

    if (idx) {
      result = splitSelectorArrB[0].every((arr, index) => {
        return arr.every((part, innerIndex) =>
          // because selectorA has more space elements, we need to slice
          // selectorA array by 'idx' number to compare them
          splitSelectorArrA[0].slice(idx)[index][innerIndex] === part)
      })
    }
  } else {
    // if selectorA has the same descendant specificity as selectorB
    // this condition covers cases such as: '.grid.foo.bar' and '.grid'
    result = splitSelectorArrB.some(byCommaArr => {
      return byCommaArr.every((bySpaceArr, index) => {
        return bySpaceArr.every(
          (part, innerIndex) => splitSelectorArrA[0][index][innerIndex] === part
        )
      })
    })
  }

  return result
}
235942
function(elementA, elementB) {

        var isSuccessor = false;
        this.search(elementA, function(element) {
            if (element === elementB && element !== elementA) {
                isSuccessor = true;
                return false;
            }
        }, { outbound: true });
        return isSuccessor;
    }
523246
def element_needs_parens?(element)
      if element.is_a?(ListLiteral)
        return false if element.elements.length < 2
        return false if element.bracketed
        return Sass::Script::Parser.precedence_of(element.separator || :space) <=
               Sass::Script::Parser.precedence_of(separator || :space)
      end

      return false unless separator == :space

      if element.is_a?(UnaryOperation)
        return element.operator == :minus || element.operator == :plus
      end

      return false unless element.is_a?(Operation)
      return true unless element.operator == :div
      !(is_literal_number?(element.operand1) && is_literal_number?(element.operand2))
    end
190180
function(sel) {
      if (!this.length) {
        return false;
      }
      var m = (this[0].matches || this[0].matchesSelector || this[0].msMatchesSelector || this[0].mozMatchesSelector || this[0].webkitMatchesSelector || this[0].oMatchesSelector || function(s) {
        return [].indexOf.call(document.querySelectorAll(s), this) !== -1;
      });
      return m.call(this[0], sel);
    }
51866
function hasInterpolatingAmpersand(selector) {
  for (let i = 0, l = selector.length; i < l; i++) {
    if (selector[i] !== "&") {
      continue;
    }

    if (!_.isUndefined(selector[i - 1]) && !isCombinator(selector[i - 1])) {
      return true;
    }

    if (!_.isUndefined(selector[i + 1]) && !isCombinator(selector[i + 1])) {
      return true;
    }
  }

  return false;
}
795223
private static boolean areEqualWithGenerics(ClassNode a, ClassNode b) {
        if (a==null) return b==null;
        if (!a.equals(b)) return false;
        if (a.isUsingGenerics() && !b.isUsingGenerics()) return false;
        GenericsType[] gta = a.getGenericsTypes();
        GenericsType[] gtb = b.getGenericsTypes();
        if (gta==null && gtb!=null) return false;
        if (gtb==null && gta!=null) return false;
        if (gta!=null && gtb!=null) {
            if (gta.length!=gtb.length) return false;
            for (int i = 0; i < gta.length; i++) {
                GenericsType ga = gta[i];
                GenericsType gb = gtb[i];
                boolean result = ga.isPlaceholder()==gb.isPlaceholder() && ga.isWildcard()==gb.isWildcard();
                result = result && ga.isResolved() && gb.isResolved();
                result = result && ga.getName().equals(gb.getName());
                result = result && areEqualWithGenerics(ga.getType(), gb.getType());
                result = result && areEqualWithGenerics(ga.getLowerBound(), gb.getLowerBound());
                if (result) {
                    ClassNode[] upA = ga.getUpperBounds();
                    if (upA!=null) {
                        ClassNode[] upB = gb.getUpperBounds();
                        if (upB==null || upB.length!=upA.length) return false;
                        for (int j = 0; j < upA.length; j++) {
                            if (!areEqualWithGenerics(upA[j],upB[j])) return false;
                        }
                    }
                }
                if (!result) return false;
            }
        }
        return true;
    }
1105687
function isBackwards(sel) {
	sel = sel || getSelection();
	if (isCollapsed(sel)) { return; }

	// Detect if selection is backwards
	var range = doc.createRange();
	range.setStart(sel.anchorNode, sel.anchorOffset);
	range.setEnd(sel.focusNode, sel.focusOffset);
	range.detach();

	// if `collapsed` then it's backwards
	return range.collapsed;
}
1276215
function ( selector ) {
            var el = this.element(),
                children = el.children;
    
            if ( typeof selector === 'string' ) {
                var elNum = children.length, result = [], i;
    
                for ( i = 0; i < elNum; ++i ) {
                    var child = children[i],
                        match = $B.selector.match( child, selector );
    
                    if ( match ) result.push( child );
                }
                return result;
            } else {
                //this.element().childNodes;
                return $B( children ).toArray();
            }
        }
1043762
function (a, b) {
			return getSpecificityScore(element, b.selectorText) - getSpecificityScore(element, a.selectorText);
		}
1242620
function selector() {
        whitespace();

        while (css[0] === '}') {
            error('extra closing bracket');
        }

        const m = match(/^(("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^{])+)/);

        if (m) {
            return m[0]
                .trim() // remove all comments from selectors
                .replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
                .replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m) {
                    return m.replace(/,/g, '\u200C');
                })
                .split(/\s*(?![^(]*\)),\s*/)
                .map(function(s) {
                    return s.replace(/\u200C/g, ',');
                });
        }
    }
234961
function (selector) {
            if (vQ.isFunction(selector)) return this.not(this.not(selector));
            return vQ(filter.call(this, function (element) {
                return vQ.matches(element, selector);
            }));
        }
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);
    }
923691
function querySelector(selector) {
    init();
    if (!selector) {
      return tokens;
    }
    var match = selector.match(
      /^\s*([\w_-]*)((\s*\[[\w_-]+\s*=\s*("([^\\"]*(\\.)*)*"|'([^\\']*(\\.)*)*'|[^\[\]]*)\])*)\s*(\*?)$/
    );
    if (!match) {
      console.warn(colors.blue('Invalid selector expressions %j.'), selector);
      return;
    }
    var tag = match[1];
    var attributes = [];
    var all = match[9] === '*';
    match[2].replace(/\s*\[([\w_-]+)\s*=\s*("([^\\"]*(\\.)*)*"|'([^\\']*(\\.)*)*'|[^\[\]]*)\]/g,
      function (match, name, value) {
        if (/^['"]/.test(value)) {
          /*jslint evil: true */
          value = new Function('return (' + value + ');')();
        }
        attributes.push({
          name: name,
          value: value
        });
      }
    );
    function check(node) {
      if (!node || !node.attrs) {
        return;
      }
      var flag;
      if (!tag || node.tag === tag) {
        flag = true;
        attributes.every(function (item) {
          if (item.value !== node.attrs[item.name]) {
            flag = false;
          }
          return flag;
        });
      }
      return flag;
    }
    var items;
    function scan(node) {
      if (check(node)) {
        if (items) {
          items.push(node);
        }
        return node;
      }
      var result;
      if (node.nodes) {
        node.nodes.every(function (item) {
          result = scan(item);
          return items || !result;
        });
      }
      return result;
    }
    if (all) {
      items = [];
      scan(tokens);
      return items;
    }
    else {
      return scan(tokens);
    }
  }
781255
function(selector) {

	var allMatches = localnwt.all(selector),
		testNode = this._node,
		ancestor = null,
		maxDepth = 0;

	if( allMatches.size() == 0 ) {
		return null;
	}

	while( true ) {

		// Iterate through all matches for each parent, and exit as soon as we have a match
		// Pretty bad performance, but super small. TODO: Omtimize
		allMatches.each(function (el) {
			if (el._node == testNode) {
				ancestor = el;
			}
		});

		var parentNode = testNode.parentNode;

		if( ancestor || !parentNode) { break; }
		testNode = parentNode;
	}

	if( ancestor ) {
		return ancestor;
	} else {
		return null;
	}
}
529445
function compareMappingsDeep(mapping1, mapping2) {
  return _.isEqualWith(mapping1, mapping2, (object1, object2, prop) => {
    let mapping1 = { [prop]: object1 }
    let mapping2 = { [prop]: object2 }
    if (prop == "from" || prop == "to") {
      if (!_.isEqual(Object.getOwnPropertyNames(_.get(object1, prop, {})), Object.getOwnPropertyNames(_.get(object2, prop, {})))) {
        return false
      }
      return _.isEqualWith(conceptsOfMapping(mapping1, prop), conceptsOfMapping(mapping2, prop), (concept1, concept2, index) => {
        if (index != undefined) {
          return compare(concept1, concept2)
        }
        return undefined
      })
    }
    if (prop == "fromScheme" || prop == "toScheme") {
      return compare(object1, object2)
    }
    // Let lodash's isEqual do the comparison
    return undefined
  })
}
1132853
function() {
  if (!global.document) {
    return true;
  }
  return global.document.documentElement.compareDocumentPosition ?
    function (a, b) {
      return !!(a.compareDocumentPosition(b) & 16);
    } :
    global.document.documentElement.contains ?
      function (a, b) {
        return a !== b && ( a.contains ? a.contains(b) : false );
      } :
      function (a, b) {
        while (b = b.parentNode) {
          if (b === a) {
            return true;
          }
        }
        return false;
      };
}
314958
function (a, b) {
        var done = this._done,
            indexOfA,
            comparedWith;
        indexOfA = done.indexOf(a);
        while (-1 < indexOfA) {
            comparedWith = this._getPair(done, indexOfA);
            if (comparedWith === b) {
                return false; // Already compared
            }
            indexOfA = done.indexOf(a, indexOfA + 1);
        }
        return true;
    }