Commit 94340607 authored by Oleg's avatar Oleg Committed by Dave Methvin

Simplify .wrapAll() and fix style. Close gh-1116.

parent b6abb31d
...@@ -29,30 +29,33 @@ jQuery.fn.extend({ ...@@ -29,30 +29,33 @@ jQuery.fn.extend({
return jQuery.access( this, function( value ) { return jQuery.access( this, function( value ) {
return value === undefined ? return value === undefined ?
jQuery.text( this ) : jQuery.text( this ) :
this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); this.empty().append( ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value ) );
}, null, value, arguments.length ); }, null, value, arguments.length );
}, },
wrapAll: function( html ) { wrapAll: function( html ) {
var wrap;
if ( jQuery.isFunction( html ) ) { if ( jQuery.isFunction( html ) ) {
return this.each(function(i) { return this.each(function( i ) {
jQuery(this).wrapAll( html.call(this, i) ); jQuery( this ).wrapAll( html.call(this, i) );
}); });
} }
if ( this[0] ) { if ( this[ 0 ] ) {
// The elements to wrap the target around // 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 ) { if ( this[ 0 ].parentNode ) {
wrap.insertBefore( this[0] ); wrap.insertBefore( this[ 0 ] );
} }
wrap.map(function() { wrap.map(function() {
var elem = this; var elem = this;
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { while ( elem.firstElementChild ) {
elem = elem.firstChild; elem = elem.firstElementChild;
} }
return elem; return elem;
...@@ -188,7 +191,7 @@ jQuery.fn.extend({ ...@@ -188,7 +191,7 @@ jQuery.fn.extend({
html: function( value ) { html: function( value ) {
return jQuery.access( this, function( value ) { return jQuery.access( this, function( value ) {
var elem = this[0] || {}, var elem = this[ 0 ] || {},
i = 0, i = 0,
l = this.length; l = this.length;
......
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