]> source.dussan.org Git - jquery.git/commitdiff
Manipulation: Tolerate XMLNode host object input to getAll
authorRichard Gibson <richard.gibson@gmail.com>
Tue, 17 Jun 2014 13:48:17 +0000 (09:48 -0400)
committerRichard Gibson <richard.gibson@gmail.com>
Thu, 4 Sep 2014 06:41:57 +0000 (02:41 -0400)
Fixes #15151
Ref 25712d77c3bc0221b5b2b9b9492c20a9cfbe1b17
Closes gh-1602

src/manipulation.js

index 887c70c0a23c4031458427f34757b8c5c533ac41..13bbbfc8e84cc042aba83918f420fd23f632b86a 100644 (file)
@@ -121,8 +121,12 @@ function cloneCopyEvent( src, dest ) {
 }
 
 function getAll( context, tag ) {
-       var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
-                       context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
+       // Support: IE9-11+
+       // Use typeof to avoid zero-argument method invocation on host objects (#15151)
+       var ret = typeof context.getElementsByTagName !== "undefined" ?
+                       context.getElementsByTagName( tag || "*" ) :
+                       typeof context.querySelectorAll !== "undefined" ?
+                               context.querySelectorAll( tag || "*" ) :
                        [];
 
        return tag === undefined || tag && jQuery.nodeName( context, tag ) ?