Skip to content

Instantly share code, notes, and snippets.

@darkwing
Created March 26, 2009 17:58
Show Gist options
  • Save darkwing/86221 to your computer and use it in GitHub Desktop.
Save darkwing/86221 to your computer and use it in GitHub Desktop.
/* digitarald's, before */
for (var i = 0, selector; (selector = parsed[i]); i++) {
var locate = locateCurrent;
if (selector.first) {
if (!results) locate = locateFast;
if (iterate) nodes = context;
else if (selector.combinator) nodes = [context]; // allows combinators before selectors
}
if (selector.last && results) {
current = all;
combined = results;
} else {
// default stack
current = {};
combined = [];
}
/* davidwalsh's after */
for (var i = 0, selector; (selector = parsed[i]); i++) {
var locate = locateCurrent, current = {}, combined = [];
if (selector.first) {
if (!results) locate = locateFast;
if (iterate) nodes = context;
else if (selector.combinator) nodes = [context]; // allows combinators before selectors
}
if (selector.last && results) {
current = all;
combined = results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment