// 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 ) {
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]);