Permalink
Browse files

A follow-up for bug #3945. ID selectors don't work in querySelectorAl…

…l on XML documents, so we just fall back to the normal engine.
  • Loading branch information...
1 parent 7d9d210 commit d45f19394866c3006b5cca733d31417395b703e6 @jeresig jeresig committed Jan 21, 2009
Showing with 5 additions and 3 deletions.
  1. +3 −1 src/selector.js
  2. +2 −2 test/unit/selector.js
View
@@ -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){}
@@ -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();
});
});

0 comments on commit d45f193

Please sign in to comment.