Manipulation: make wrapAll funarg execute only once

Ref 359b03cac7
This commit is contained in:
Oleg Gaidarenko
2014-12-24 01:56:21 +03:00
parent ae30fb6c27
commit 3dcee02160
2 changed files with 69 additions and 9 deletions

View File

@@ -7,18 +7,18 @@ define([
jQuery.fn.extend({
wrapAll: function( html ) {
if ( jQuery.isFunction( html ) ) {
return this.each(function(i) {
jQuery(this).wrapAll( html.call(this, i) );
});
}
var wrap;
if ( this[ 0 ] ) {
if ( jQuery.isFunction( html ) ) {
html = html.call( this[ 0 ] );
}
if ( this[0] ) {
// The elements to wrap the target around
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
if ( this[0].parentNode ) {
wrap.insertBefore( this[0] );
if ( this[ 0 ].parentNode ) {
wrap.insertBefore( this[ 0 ] );
}
wrap.map(function() {