]> source.dussan.org Git - jquery.git/commitdiff
$("#foo", xml) would always return an empty set, fixed (bug #877). Additionally,...
authorJohn Resig <jeresig@gmail.com>
Wed, 25 Jul 2007 00:56:50 +0000 (00:56 +0000)
committerJohn Resig <jeresig@gmail.com>
Wed, 25 Jul 2007 00:56:50 +0000 (00:56 +0000)
src/jquery/jquery.js
src/selector/selector.js

index 8a2c6b2c0c2e36b88f2e8e0e2a7f9d7202a6b6d2..6f4bbe3fb93f7396b504c15e6f12c49f882e59a2 100644 (file)
@@ -1318,7 +1318,8 @@ jQuery.extend({
        
        // check if an element is in a XML document
        isXMLDoc: function(elem) {
-               return elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
+               return elem.documentElement && !elem.body ||
+                       elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
        },
 
        nodeName: function( elem, name ) {
index 2cf0b640417b03fa2cb5535a3a6379afdb589fb9..366cf31883016498e6dd379d146cd7d97239e25f 100644 (file)
@@ -213,7 +213,7 @@ jQuery.extend({
                                        var elem = ret[ret.length-1];
 
                                        // Try to do a global search by ID, where we can
-                                       if ( m[1] == "#" && elem && elem.getElementById ) {
+                                       if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
                                                // Optimization for HTML document case
                                                var oid = elem.getElementById(m[2]);