mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Core: Make jQuery.isXMLDoc accept falsy input
Fixes gh-4782 Closes gh-4814
This commit is contained in:
parent
dbcffb396c
commit
fd421097c5
@ -307,8 +307,8 @@ jQuery.extend( {
|
|||||||
},
|
},
|
||||||
|
|
||||||
isXMLDoc: function( elem ) {
|
isXMLDoc: function( elem ) {
|
||||||
var namespace = elem.namespaceURI,
|
var namespace = elem && elem.namespaceURI,
|
||||||
docElem = ( elem.ownerDocument || elem ).documentElement;
|
docElem = elem && ( elem.ownerDocument || elem ).documentElement;
|
||||||
|
|
||||||
// Assume HTML when documentElement doesn't yet exist, such as inside
|
// Assume HTML when documentElement doesn't yet exist, such as inside
|
||||||
// document fragments.
|
// document fragments.
|
||||||
|
@ -417,6 +417,16 @@ QUnit.test( "isXMLDoc - XML", function( assert ) {
|
|||||||
assert.ok( jQuery.isXMLDoc( jQuery( "desc", svg )[ 0 ] ), "XML desc Element" );
|
assert.ok( jQuery.isXMLDoc( jQuery( "desc", svg )[ 0 ] ), "XML desc Element" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
QUnit.test( "isXMLDoc - falsy", function( assert ) {
|
||||||
|
assert.expect( 5 );
|
||||||
|
|
||||||
|
assert.strictEqual( jQuery.isXMLDoc( undefined ), false, "undefined" );
|
||||||
|
assert.strictEqual( jQuery.isXMLDoc( null ), false, "null" );
|
||||||
|
assert.strictEqual( jQuery.isXMLDoc( false ), false, "false" );
|
||||||
|
assert.strictEqual( jQuery.isXMLDoc( 0 ), false, "0" );
|
||||||
|
assert.strictEqual( jQuery.isXMLDoc( "" ), false, "\"\"" );
|
||||||
|
} );
|
||||||
|
|
||||||
QUnit.test( "XSS via location.hash", function( assert ) {
|
QUnit.test( "XSS via location.hash", function( assert ) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
assert.expect( 1 );
|
assert.expect( 1 );
|
||||||
|
Loading…
Reference in New Issue
Block a user