From d45f19394866c3006b5cca733d31417395b703e6 Mon Sep 17 00:00:00 2001 From: John Resig Date: Wed, 21 Jan 2009 23:31:29 +0000 Subject: [PATCH] A follow-up for bug #3945. ID selectors don't work in querySelectorAll on XML documents, so we just fall back to the normal engine. --- src/selector.js | 4 +++- test/unit/selector.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/selector.js b/src/selector.js index a2507461..553df98e 100644 --- a/src/selector.js +++ b/src/selector.js @@ -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){} diff --git a/test/unit/selector.js b/test/unit/selector.js index 07671c6b..a648e33d 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -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(); }); });