Skip to content
Permalink
Browse files

$("#foo", xml) would always return an empty set, fixed (bug #877). Ad…

…ditionally, a bug in jQuery.isXMLDoc(xmlDoc) was discovered, if the element was, in fact, an XML document.
  • Loading branch information
jeresig committed Jul 25, 2007
1 parent bdf05d8 commit f8b00051c377360f0106e56c24df1353aaf6ad44
Showing with 3 additions and 2 deletions.
  1. +2 −1 src/jquery/jquery.js
  2. +1 −1 src/selector/selector.js
@@ -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 ) {
@@ -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]);

0 comments on commit f8b0005

Please sign in to comment.
You can’t perform that action at this time.