A follow-up for bug #3945. ID selectors don't work in querySelectorAll on XML documen...
authorJohn Resig <jeresig@gmail.com>
Wed, 21 Jan 2009 23:31:29 +0000 (23:31 +0000)
committerJohn Resig <jeresig@gmail.com>
Wed, 21 Jan 2009 23:31:29 +0000 (23:31 +0000)
src/selector.js
test/unit/selector.js

index a250746..553df98 100644 (file)
@@ -723,7 +723,9 @@ if ( document.querySelectorAll ) (function(){
        Sizzle = function(query, context, extra, seed){
                context = context || document;
 
-               if ( !seed && context.nodeType === 9 ) {
+               // Only use querySelectorAll on non-XML documents
+               // (ID selectors don't work in non-HTML documents)
+               if ( !seed && context.nodeType === 9 && !isXML(context) ) {
                        try {
                                return makeArray( context.querySelectorAll(query), extra );
                        } catch(e){}
index 07671c6..a648e33 100644 (file)
@@ -28,8 +28,8 @@ if ( location.protocol != "file:" ) {
                        equals( jQuery("foo_bar", xml).length, 1, "Element Selector with underscore" );
                        equals( jQuery("property[name=prop2]", xml).length, 1, "Attribute selector with name" );
                        equals( jQuery("[name=prop2]", xml).length, 1, "Attribute selector with name" );
-                       equals( jQuery("#seite1", xml).length, 1, "Attribute selector with name" );
-                       equals( jQuery("component#seite1", xml).length, 1, "Attribute selector with name" );
+                       equals( jQuery("#seite1", xml).length, 1, "Attribute selector with ID" );
+                       equals( jQuery("component#seite1", xml).length, 1, "Attribute selector with ID" );
                        start();
                });
        });