-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Description
Description
isXMLDoc() throws an error if undefined given, starting from version 3.4.0
Test script:
jQuery.isXMLDoc(undefined)
jQuery 3.3.1 result:
false
jQuery 3.5.1 (currently the latest, but starting from 3.4.0) result:
Uncaught TypeError: Cannot read property 'namespaceURI' of undefined
Techinfo
Before the Sizzle update from 2.3.3 to 2.3.4 (see related commit below), isXML() function looked liked this:
isXML = Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833)
var documentElement = elem && (elem.ownerDocument || elem).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false;
};
This doesn't throw an error, when the elem is undefined, because it checks it.
In the update from 3.4.0, it looks like this:
isXML = Sizzle.isXML = function( elem ) {
var namespace = elem.namespaceURI,
docElem = ( elem.ownerDocument || elem ).documentElement;
// Support: IE <=8
// Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
// https://bugs.jquery.com/ticket/4833
return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
};
This throws an error when the elem is undefined:
Uncaught TypeError: Cannot read property 'namespaceURI' of undefined
Please, if you can, bring back the previous functionality: undefined is not an XML node, so it should return a false boolean instead of a TypeError.
Thanks in advance!
Additional info
Related commit: d940bc0 (from line 562)
Related blog-post: https://blog.jquery.com/2019/04/10/jquery-3-4-0-released/