Commit 61d01c8d authored by Oleg's avatar Oleg

Simplify getAll helper

parent 7a5000a3
...@@ -448,11 +448,10 @@ jQuery.each({ ...@@ -448,11 +448,10 @@ jQuery.each({
last = insert.length - 1; last = insert.length - 1;
for ( ; i <= last; i++ ) { for ( ; i <= last; i++ ) {
elems = i === last ? this : this.clone(true); elems = i === last ? this : this.clone( true );
jQuery( insert[ i ] )[ original ]( elems ); jQuery( insert[ i ] )[ original ]( elems );
// Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() core_push.apply( ret, elems );
core_push.apply( ret, elems.get() );
} }
return this.pushStack( ret ); return this.pushStack( ret );
...@@ -462,23 +461,22 @@ jQuery.each({ ...@@ -462,23 +461,22 @@ jQuery.each({
function getAll( context, tag ) { function getAll( context, tag ) {
var elems, elem, var elems, elem,
i = 0, i = 0,
found = typeof context.getElementsByTagName !== "undefined" ? context.getElementsByTagName( tag || "*" ) : ret = typeof context.getElementsByTagName !== "undefined" ? context.getElementsByTagName( tag || "*" ) :
typeof context.querySelectorAll !== "undefined" ? context.querySelectorAll( tag || "*" ) : typeof context.querySelectorAll !== "undefined" ? context.querySelectorAll( tag || "*" ) :
undefined; undefined;
if ( !found ) { if ( !ret ) {
for ( found = [], elems = context.childNodes || context; (elem = elems[ i ]) != null; i++ ) { for ( ret = [], elems = context.childNodes || context; (elem = elems[ i ]) != null; i++ ) {
if ( !tag || jQuery.nodeName( elem, tag ) ) { core_push.apply( ret,
found.push( elem ); !tag || jQuery.nodeName( elem, tag ) ?
} else { getAll( elem, tag ) :
jQuery.merge( found, getAll( elem, tag ) ); elems );
}
} }
} }
return tag === undefined || tag && jQuery.nodeName( context, tag ) ? return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
jQuery.merge( [ context ], found ) : jQuery.merge( [ context ], ret ) :
found; ret;
} }
// Used in clean, fixes the defaultChecked property // Used in clean, fixes the defaultChecked property
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment