From fac7e61f16130b29d5444fab12628a5eeea885cf Mon Sep 17 00:00:00 2001 From: jeresig Date: Sun, 10 Oct 2010 15:42:56 -0400 Subject: [PATCH] Tweaking some formatting of the closest changes. --- src/traversing.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/traversing.js b/src/traversing.js index c473c758..de250e6c 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -62,14 +62,13 @@ jQuery.fn.extend({ }, closest: function( selectors, context ) { - var ret; + var ret = [], i, l, cur = this[0]; if ( jQuery.isArray( selectors ) ) { - var cur = this[0], match, matches = {}, selector, level = 1; - ret = []; + var match, matches = {}, selector, level = 1; if ( cur && selectors.length ) { - for ( var i = 0, l = selectors.length; i < l; i++ ) { + for ( i = 0, l = selectors.length; i < l; i++ ) { selector = selectors[i]; if ( !matches[selector] ) { @@ -99,10 +98,8 @@ jQuery.fn.extend({ var pos = POS.test( selectors ) ? jQuery( selectors, context || this.context ) : null; - ret = []; - - for ( var i = 0, j = this.length; i < j; i++ ) { - var cur = this[i]; + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; while ( cur ) { if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {