Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better fix for #31

  • Loading branch information...
commit cb2e8f67738f269451d8373cb220555da8e87f29 1 parent 394c5ff
@arian arian authored
Showing with 23 additions and 21 deletions.
  1. +19 −8 SlickSpec/specs/html.js
  2. +4 −13 Source/Slick.Finder.js
View
27 SlickSpec/specs/html.js
@@ -32,16 +32,27 @@ describe('Slick', function(){
itShouldFind(2, 'body [tabindex="1"]');
itShouldFind(4, 'body [tabindex]');
- it('should find `~`', function(){
- expect(context.SELECT1(context.document.getElementById('one'), '~')).not.toBeNull();
- });
- it('should find `~div`', function(){
- expect(context.SELECT1(context.document.getElementById('one'), '~div')).not.toBeNull();
- });
- it('should find `> i`', function(){
- expect(context.SELECT1(context.document.getElementById('one'), '> i')).not.toBeNull();
+ describe('Combinators', function(){
+
+ it('should find `~`', function(){
+ expect(context.SELECT1(context.document.getElementById('one'), '~')).not.toBeNull();
+ });
+ it('should find `~div`', function(){
+ expect(context.SELECT1(context.document.getElementById('one'), '~div')).not.toBeNull();
+ });
+ it('should find `> i`', function(){
+ expect(context.SELECT1(context.document.getElementById('one'), '> i')).not.toBeNull();
+ });
+ it('should find `+`', function(){
+ expect(context.SELECT1(context.document.getElementById('one'), '+')).not.toBeNull();
+ });
+ it('should find `+div`', function(){
+ expect(context.SELECT1(context.document.getElementById('one'), '+div')).not.toBeNull();
+ });
+
});
+
});
};
View
17 Source/Slick.Finder.js
@@ -63,7 +63,6 @@ local.setDocument = function(document){
= features.brokenMixedCaseQSA
= features.brokenGEBCN
= features.brokenCheckedQSA
- = features.brokenGeneralSiblingCombinator
= features.brokenEmptyAttributeQSA
= features.isHTMLDocument
= features.nativeMatchesSelector
@@ -147,13 +146,6 @@ local.setDocument = function(document){
features.brokenCheckedQSA = (testNode.querySelectorAll(':checked').length == 0);
} catch(e){};
- try {
- testNode.innerHTML = '<div id="foo"></div><div></div>';
- features.brokenGeneralSiblingCombinator = !(testNode.getElementById('foo').querySelector('~ div'));
- } catch(e){
- features.brokenGeneralSiblingCombinator = true;
- }
-
// IE returns incorrect results for attr[*^$]="" selectors on querySelectorAll
try {
testNode.innerHTML = '<a class=""></a>';
@@ -336,13 +328,12 @@ local.search = function(context, expression, append, first){
/*<query-selector-override>*/
querySelector: if (context.querySelectorAll) {
-
if (!this.isHTMLDocument || this.brokenMixedCaseQSA || qsaFailExpCache[expression] ||
(this.brokenCheckedQSA && expression.indexOf(':checked') > -1) ||
- (this.brokenGeneralSiblingCombinator) ||
(this.brokenEmptyAttributeQSA && reEmptyAttribute.test(expression)) || Slick.disableQSA) break querySelector;
- var _expression = expression;
+ var _expression = expression,
+ _context = context.parentNode;
if (!contextIsDocument){
// non-document rooted QSA
// credits to Andrew Dupont
@@ -352,8 +343,8 @@ local.search = function(context, expression, append, first){
}
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;
Please sign in to comment.
Something went wrong with that request. Please try again.