Skip to content

Commit

Permalink
added back a better optimization for general siblings combinator remo…
Browse files Browse the repository at this point in the history
…ved in previous commits
  • Loading branch information
dperini committed Mar 21, 2009
1 parent 1aa594b commit 8777e3b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/nwmatcher.js
Expand Up @@ -426,6 +426,8 @@ NW.Dom = function(global) {

var i, a, b, n, k, expr, match, result, status, test, type;

k = 0;

while (selector) {

// *** Universal selector
Expand Down Expand Up @@ -480,7 +482,12 @@ NW.Dom = function(global) {
// *** General sibling combinator
// E ~ F (F relative sibling of E)
else if ((match = selector.match(Patterns.relative))) {
source = 'while((e=e.previousSibling)){if(e.nodeType==1){' + source + '}}';
// previousSibling particularly slow on Gecko based browsers prior to FF3.1
//source = 'while((e=e.previousSibling)){if(e.nodeType==1){' + source + '}}';
k++;
source =
'var N' + k + '=e;e=e.parentNode.firstChild;' +
'while((e=e.nextSibling)&&e!=N' + k + '){if(e.nodeType==1){' + source + '}}';
}
// *** Child combinator
// E > F (F children of E)
Expand Down

0 comments on commit 8777e3b

Please sign in to comment.