4 "./manipulation", // clone
5 "./traversing" // parent, contents
6 ], function( jQuery ) {
11 wrapAll: function( html ) {
15 if ( jQuery.isFunction( html ) ) {
16 html = html.call( this[ 0 ] );
19 // The elements to wrap the target around
20 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
22 if ( this[ 0 ].parentNode ) {
23 wrap.insertBefore( this[ 0 ] );
26 wrap.map( function() {
29 while ( elem.firstElementChild ) {
30 elem = elem.firstElementChild;
40 wrapInner: function( html ) {
41 if ( jQuery.isFunction( html ) ) {
42 return this.each( function( i ) {
43 jQuery( this ).wrapInner( html.call( this, i ) );
47 return this.each( function() {
48 var self = jQuery( this ),
49 contents = self.contents();
51 if ( contents.length ) {
52 contents.wrapAll( html );
60 wrap: function( html ) {
61 var isFunction = jQuery.isFunction( html );
63 return this.each( function( i ) {
64 jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
68 unwrap: function( selector ) {
69 this.parent( selector ).not( "body" ).each( function() {
70 jQuery( this ).replaceWith( this.childNodes );