X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fmanipulation.js;h=0c2753e968200c98c7b983ebfaf58f649740ded9;hb=f6a0bf6816f4e2e67382b1b13fdd3ff2ea4b22f8;hp=789bf54e788d91a3ae9132756d63b5e85599c25b;hpb=098a2bb4d0eec2d590c222bb04bcdda7e1dcd169;p=jquery.git diff --git a/src/manipulation.js b/src/manipulation.js index 789bf54..0c2753e 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -4,7 +4,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, rtagName = /<([\w:]+)/, rtbody = /", "" ], td: [ 3, "", "
" ], col: [ 2, "", "
" ], + area: [ 1, "", "" ], _default: [ 0, "", "" ] }; @@ -31,22 +32,11 @@ if ( !jQuery.support.htmlSerialize ) { jQuery.fn.extend({ text: function( text ) { - if ( typeof text !== "object" && text !== undefined ) + if ( typeof text !== "object" && text !== undefined ) { return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); + } - var ret = ""; - - jQuery.each( text || this, function(){ - jQuery.each( this.childNodes, function(){ - if ( this.nodeType !== 8 ) { - ret += this.nodeType !== 1 ? - this.nodeValue : - jQuery.fn.text( [ this ] ); - } - }); - }); - - return ret; + return jQuery.getText( this ); }, wrapAll: function( html ) { @@ -58,7 +48,7 @@ jQuery.fn.extend({ if ( this[0] ) { // The elements to wrap the target around - var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(); + var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); if ( this[0].parentNode ) { wrap.insertBefore( this[0] ); @@ -166,21 +156,8 @@ jQuery.fn.extend({ // Copy the events from the original to the clone if ( events === true ) { - var orig = this.find("*").andSelf(), i = 0; - - ret.find("*").andSelf().each(function(){ - if ( this.nodeName !== orig[i].nodeName ) { return; } - - var events = jQuery.data( orig[i], "events" ); - - for ( var type in events ) { - for ( var handler in events[ type ] ) { - jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); - } - } - - i++; - }); + cloneCopyEvent( this, ret ); + cloneCopyEvent( this.find("*"), ret.find("*") ); } // Return the cloned set @@ -195,7 +172,7 @@ jQuery.fn.extend({ // See if we can take a shortcut and just use innerHTML } else if ( typeof value === "string" && !/