Created
April 19, 2011 11:21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var reSingularCombinator = /^\!?[>+^]$/; // "+", ">", "^" | |
local.matchNodeR = function(node, selector, needle){ | |
var parsed = this.Slick.parse(selector); | |
if (!parsed) return true; | |
parsed = parsed.reverse(); | |
for (var i = 0, expression, expressions, built, length, multiple; expression = parsed.expressions[i]; i++) { | |
var first = expression[0]; | |
if (local.matchSelector(node, first.tag.toUpperCase(), first.id, first.classes, first.attributes, first.pseudos)) { // matching first selector against element | |
if ((length = expression.length) == 1) continue; | |
if (!built) built = {Slick: true, expressions: [], length: 0}; | |
built.expressions.push(expressions = []); | |
built.length++; | |
for (var j = 1; j < length; j++) expressions.push(expression[j]); | |
if (!multiple) multiple = !expression[expression.length - 1].combinator.match(reSingularCombinator); | |
} else return false; | |
} | |
var found = built ? this.search(node, built, null, !(multiple && needle)) : node; | |
return needle ? (multiple ? found.indexOf(needle) > -1 : found == needle) : !!found; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment