Permalink
Browse files

Fix #31 - only select the parentNode if context is not the document

  • Loading branch information...
arian committed Mar 9, 2011
1 parent cb2e8f6 commit 1b30ca3e360c28c91d48bf3226d0723447d0d28c
Showing with 9 additions and 8 deletions.
  1. +9 −8 Source/Slick.Finder.js
View
@@ -332,27 +332,28 @@ local.search = function(context, expression, append, first){
(this.brokenCheckedQSA && expression.indexOf(':checked') > -1) ||
(this.brokenEmptyAttributeQSA && reEmptyAttribute.test(expression)) || Slick.disableQSA) break querySelector;
- var _expression = expression,
- _context = context.parentNode;
+ var _expression = expression, _context = context;
if (!contextIsDocument){
// non-document rooted QSA
// credits to Andrew Dupont
- var currentId = context.getAttribute('id'), slickid = 'slickid__';
- context.setAttribute('id', slickid);
+ var currentId = _context.getAttribute('id'), slickid = 'slickid__';
+ _context.setAttribute('id', slickid);
_expression = '#' + slickid + ' ' + _expression;
+ context = _context.parentNode;
}
try {
- if (first) return _context.querySelector(_expression) || null;
- else nodes = _context.querySelectorAll(_expression);
+ if (first) return context.querySelector(_expression) || null;
+ else nodes = context.querySelectorAll(_expression);
} catch(e) {
qsaFailExpCache[expression] = 1;
break querySelector;
} finally {
if (!contextIsDocument){
- if (currentId) context.setAttribute('id', currentId);
- else context.removeAttribute('id');
+ if (currentId) _context.setAttribute('id', currentId);
+ else _context.removeAttribute('id');
}
+ context = _context;
}
if (this.starSelectsClosedQSA) for (i = 0; node = nodes[i++];){

0 comments on commit 1b30ca3

Please sign in to comment.