File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -307,8 +307,8 @@ jQuery.extend( {
307
307
} ,
308
308
309
309
isXMLDoc : function ( elem ) {
310
- var namespace = elem . namespaceURI ,
311
- docElem = ( elem . ownerDocument || elem ) . documentElement ;
310
+ var namespace = elem && elem . namespaceURI ,
311
+ docElem = elem && ( elem . ownerDocument || elem ) . documentElement ;
312
312
313
313
// Assume HTML when documentElement doesn't yet exist, such as inside
314
314
// document fragments.
Original file line number Diff line number Diff line change @@ -417,6 +417,16 @@ QUnit.test( "isXMLDoc - XML", function( assert ) {
417
417
assert . ok ( jQuery . isXMLDoc ( jQuery ( "desc" , svg ) [ 0 ] ) , "XML desc Element" ) ;
418
418
} ) ;
419
419
420
+ QUnit . test ( "isXMLDoc - falsy" , function ( assert ) {
421
+ assert . expect ( 5 ) ;
422
+
423
+ assert . strictEqual ( jQuery . isXMLDoc ( undefined ) , false , "undefined" ) ;
424
+ assert . strictEqual ( jQuery . isXMLDoc ( null ) , false , "null" ) ;
425
+ assert . strictEqual ( jQuery . isXMLDoc ( false ) , false , "false" ) ;
426
+ assert . strictEqual ( jQuery . isXMLDoc ( 0 ) , false , "0" ) ;
427
+ assert . strictEqual ( jQuery . isXMLDoc ( "" ) , false , "\"\"" ) ;
428
+ } ) ;
429
+
420
430
QUnit . test ( "XSS via location.hash" , function ( assert ) {
421
431
var done = assert . async ( ) ;
422
432
assert . expect ( 1 ) ;
You can’t perform that action at this time.
0 commit comments