Skip to content

Commit

Permalink
Fixes #1019 - results for attr[*^$]="" selectors on querySelectorAll …
Browse files Browse the repository at this point in the history
…are now working fine with IE8
  • Loading branch information
fabiomcosta committed Sep 29, 2010
1 parent 105fc63 commit 2f290af
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Source/Slick.Finder.js
Expand Up @@ -44,6 +44,7 @@ local.setDocument = function(document){
= this.brokenMixedCaseQSA
= this.brokenGEBCN
= this.brokenCheckedQSA
= this.brokenEmptyAttributeQSA
= this.isHTMLDocument
= false;

Expand Down Expand Up @@ -113,12 +114,18 @@ local.setDocument = function(document){

this.brokenGEBCN = cachedGetElementsByClassName || brokenSecondClassNameGEBCN;

// Webkit dont return selected options on QSA
// Webkit dont return selected options on querySelectorAll
try {
testNode.innerHTML = '<select><option selected="selected">a</option></select>';
this.brokenCheckedQSA = (testNode.querySelectorAll(':checked').length == 0);
} catch(e){};

// IE returns incorrect results for attr[*^$]="" selectors on querySelectorAll
try {
testNode.innerHTML = '<a class=""></a>';
this.brokenEmptyAttributeQSA = (testNode.querySelectorAll('[class*=""]').length != 0);
} catch(e){};

}

root.removeChild(testNode);
Expand Down Expand Up @@ -721,10 +728,13 @@ local.override = function(regexp, method){

/*<query-selector-override>*/

var reEmptyAttribute = /\[.*[*$^]=(?:["']{2})?\]/;

local.override(/./, function(expression, found, first){ //querySelectorAll override

if (!this.querySelectorAll || this.nodeType != 9 || !local.isHTMLDocument || local.brokenMixedCaseQSA ||
(local.brokenCheckedQSA && expression.indexOf(':checked') > -1) || Slick.disableQSA) return false;
(local.brokenCheckedQSA && expression.indexOf(':checked') > -1) ||
(local.brokenEmptyAttributeQSA && reEmptyAttribute.test(expression)) || Slick.disableQSA) return false;

var nodes, node;
try {
Expand Down

0 comments on commit 2f290af

Please sign in to comment.