diff options
Diffstat (limited to 'src/manipulation/getAll.js')
-rw-r--r-- | src/manipulation/getAll.js | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/manipulation/getAll.js b/src/manipulation/getAll.js index 85490d50e..f68e3219e 100644 --- a/src/manipulation/getAll.js +++ b/src/manipulation/getAll.js @@ -8,15 +8,23 @@ function getAll( context, tag ) { // Support: IE <=9 - 11 only // 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 ) ? - jQuery.merge( [ context ], ret ) : - ret; + var ret; + + if ( typeof context.getElementsByTagName !== "undefined" ) { + ret = context.getElementsByTagName( tag || "*" ); + + } else if ( typeof context.querySelectorAll !== "undefined" ) { + ret = context.querySelectorAll( tag || "*" ); + + } else { + ret = []; + } + + if ( tag === undefined || tag && jQuery.nodeName( context, tag ) ) { + return jQuery.merge( [ context ], ret ); + } + + return ret; } return getAll; |