Permalink
Browse files

Fix #31 - `~ div` would throw when QSA was used

  • Loading branch information...
1 parent a2796ca commit 394c5ff310aea1f723540a70766fad5ffed5db70 @arian arian committed Mar 9, 2011
Showing with 27 additions and 4 deletions.
  1. +1 −1 SlickSpec/Configuration.js
  2. +4 −0 SlickSpec/mocks/query_test-slick.html
  3. +2 −2 SlickSpec/setup.js
  4. +11 −1 SlickSpec/specs/html.js
  5. +9 −0 Source/Slick.Finder.js
@@ -21,7 +21,7 @@ Configuration.sets = {
'specs': {
path: 'specs/',
files: [
- 'unit', 'syntax', 'api', 'engine_bugs', 'html', 'html5',
+ 'unit', 'syntax', 'api', 'engine_bugs', 'html', 'html5',
'select_nth-child', 'select_exhaustive', 'mock_template',
'isxml', 'xml',
'match', 'parser',
@@ -12,5 +12,9 @@
<div id="divtabindex0" tabindex="0">some</div>
<div id="divtabindex1" tabindex="1">some</div>
<div id="divtabindexnull">some</div>
+
+ <div id="one"><i>text</i></div>
+ <div id="two"></div>
+
</body>
</html>
View
@@ -19,7 +19,7 @@ global.onload = function(){
if (!Browser.ie || Browser.version > 8){
Mock.CreateTemplate('Generic XHTML', '../mocks/template.xhtml');
Mock.CreateTemplate('Generic XML', '../mocks/template.xml');
- Mock.CreateTemplate('SVG', '../mocks/mootools_logo.svg');
+ Mock.CreateTemplate('SVG', '../mocks/MooTools_Logo.svg');
}
if (Browser.ie){
@@ -39,7 +39,7 @@ global.onload = function(){
new Mock.Request('XML responseXML', '../mocks/xml.xml');
- new Mock.Request('SVG responseXML', '../mocks/mootools_logo.svg');
+ new Mock.Request('SVG responseXML', '../mocks/MooTools_Logo.svg');
// Setup
View
@@ -32,6 +32,16 @@ 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();
+ });
+
});
-};
+};
View
@@ -63,6 +63,7 @@ local.setDocument = function(document){
= features.brokenMixedCaseQSA
= features.brokenGEBCN
= features.brokenCheckedQSA
+ = features.brokenGeneralSiblingCombinator
= features.brokenEmptyAttributeQSA
= features.isHTMLDocument
= features.nativeMatchesSelector
@@ -146,6 +147,13 @@ 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>';
@@ -331,6 +339,7 @@ local.search = function(context, expression, append, first){
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;

0 comments on commit 394c5ff

Please sign in to comment.