aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg <markelog@gmail.com>2013-01-07 15:48:44 +0400
committerDave Methvin <dave.methvin@gmail.com>2013-01-08 01:35:55 +0000
commit9434060722b7b935f61f8fb6c97a2a424255dc5d (patch)
treeb747ff25db321b65cb2e75af4a0cf3783fe6214b
parentb6abb31df4d5be80dc13844d9988fb0c990ae5ae (diff)
downloadjquery-9434060722b7b935f61f8fb6c97a2a424255dc5d.tar.gz
jquery-9434060722b7b935f61f8fb6c97a2a424255dc5d.zip
Simplify .wrapAll() and fix style. Close gh-1116.
-rw-r--r--src/manipulation.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index 9aea16f9d..0ceb9ac88 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -29,30 +29,33 @@ jQuery.fn.extend({
return jQuery.access( this, function( value ) {
return value === undefined ?
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 );
},
wrapAll: function( html ) {
+ var wrap;
+
if ( jQuery.isFunction( html ) ) {
- return this.each(function(i) {
- jQuery(this).wrapAll( html.call(this, i) );
+ return this.each(function( i ) {
+ jQuery( this ).wrapAll( html.call(this, i) );
});
}
- if ( 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() {
var elem = this;
- while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
- elem = elem.firstChild;
+ while ( elem.firstElementChild ) {
+ elem = elem.firstElementChild;
}
return elem;
@@ -188,7 +191,7 @@ jQuery.fn.extend({
html: function( value ) {
return jQuery.access( this, function( value ) {
- var elem = this[0] || {},
+ var elem = this[ 0 ] || {},
i = 0,
l = this.length;