Skip to content
Permalink
Browse files

Simplify getAll helper

  • Loading branch information
markelog committed Dec 24, 2012
1 parent fa3dad3 commit 25712d77c3bc0221b5b2b9b9492c20a9cfbe1b17
Showing with 3 additions and 13 deletions.
  1. +3 −13 src/manipulation.js
@@ -613,19 +613,9 @@ function cloneCopyEvent( src, dest ) {
}

function getAll( context, tag ) {
var elems, elem,
i = 0,
ret = typeof context.getElementsByTagName !== "undefined" ? context.getElementsByTagName( tag || "*" ) :
typeof context.querySelectorAll !== "undefined" ? context.querySelectorAll( tag || "*" ) :
undefined;

if ( !ret ) {
for ( ret = [], elems = context.childNodes || context; (elem = elems[ i ]) != null; i++ ) {
core_push.apply( ret, !tag || jQuery.nodeName( elem, tag ) ?
getAll( elem, tag ) :
elems );
}
}
var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
[];

return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
jQuery.merge( [ context ], ret ) :

5 comments on commit 25712d7

@fabiomcosta

This comment has been minimized.

Copy link

fabiomcosta replied Jul 3, 2013

I know this wasn't introduced by your change but what is the reason to try querySelectorAll as a fallback to getElementsByTagName? In which case getElementsByTagName is not supported and querySelectorAll is?

@markelog

This comment has been minimized.

Copy link
Member Author

markelog replied Jul 3, 2013

getElementsByTagName is not implemented in documentFragment but qSA is

@fabiomcosta

This comment has been minimized.

Copy link

fabiomcosta replied Jul 3, 2013

Thank you for the quick response! That's terrible... why did they do this? :/ oh well...

@scottgonzalez

This comment has been minimized.

Copy link
Member

scottgonzalez replied Jul 4, 2013

See the WHATWG thread starting here.

@mgol

This comment has been minimized.

Copy link
Member

mgol replied Aug 28, 2019

For anyone wanting to see that WHATWG thread, the URL is dead, here is a one that works: https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jun/0207.html

Please sign in to comment.
You can’t perform that action at this time.