From 4d3050b3d80dc58cdcca0ce7bfdd780e50b0483f Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Tue, 19 Jan 2016 13:04:37 -0500 Subject: [PATCH] Traversing: restore jQuery push behavior in .find Fixes gh-2370 Close gh-2848 --- src/traversing/findFilter.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/traversing/findFilter.js b/src/traversing/findFilter.js index f3a929e53..913034933 100644 --- a/src/traversing/findFilter.js +++ b/src/traversing/findFilter.js @@ -53,9 +53,8 @@ jQuery.filter = function( expr, elems, not ) { jQuery.fn.extend( { find: function( selector ) { - var i, + var i, ret, len = this.length, - ret = [], self = this; if ( typeof selector !== "string" ) { @@ -68,11 +67,13 @@ jQuery.fn.extend( { } ) ); } + ret = this.pushStack( [] ); + for ( i = 0; i < len; i++ ) { jQuery.find( selector, self[ i ], ret ); } - return this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret ); + return len > 1 ? jQuery.uniqueSort( ret ) : ret; }, filter: function( selector ) { return this.pushStack( winnow( this, selector || [], false ) );