diff options
author | Oleg <markelog@gmail.com> | 2012-06-28 04:55:36 +0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-07-06 09:48:52 -0400 |
commit | 05aff402310d7db5d15f96b15071af6aa21a2afc (patch) | |
tree | 7c4dba23c514ce8a4562969793c48ae3e05a6df3 /src/manipulation.js | |
parent | f8baea8f7a8b23d0e25c0dc82670fbe48b9bf587 (diff) | |
download | jquery-05aff402310d7db5d15f96b15071af6aa21a2afc.tar.gz jquery-05aff402310d7db5d15f96b15071af6aa21a2afc.zip |
Optimization of array operations, closes gh-844.
Diffstat (limited to 'src/manipulation.js')
-rw-r--r-- | src/manipulation.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index 9ca6b0a17..fafccffbb 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -146,10 +146,11 @@ jQuery.fn.extend({ return this.domManip(arguments, false, function( elem ) { this.parentNode.insertBefore( elem, this ); }); - } else if ( arguments.length ) { + } + + if ( arguments.length ) { var set = jQuery.clean( arguments ); - set.push.apply( set, this.toArray() ); - return this.pushStack( set, "before", arguments ); + return this.pushStack( jQuery.merge( set, this ), "before", this.selector ); } }, @@ -158,10 +159,11 @@ jQuery.fn.extend({ return this.domManip(arguments, false, function( elem ) { this.parentNode.insertBefore( elem, this.nextSibling ); }); - } else if ( arguments.length ) { - var set = this.pushStack( this, "after", arguments ); - set.push.apply( set, jQuery.clean(arguments) ); - return set; + } + + if ( arguments.length ) { + var set = jQuery.clean( arguments ); + return this.pushStack( jQuery.merge( this, set ), "after", this.selector ); } }, |