4 "./manipulation", // clone
5 "./traversing" // parent, contents
6 ], function( jQuery ) {
9 wrapAll: function( html ) {
13 if ( jQuery.isFunction( html ) ) {
14 html = html.call( this[ 0 ] );
17 // The elements to wrap the target around
18 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
20 if ( this[ 0 ].parentNode ) {
21 wrap.insertBefore( this[ 0 ] );
27 while ( elem.firstElementChild ) {
28 elem = elem.firstElementChild;
38 wrapInner: function( html ) {
39 if ( jQuery.isFunction( html ) ) {
40 return this.each(function( i ) {
41 jQuery( this ).wrapInner( html.call(this, i) );
45 return this.each(function() {
46 var self = jQuery( this ),
47 contents = self.contents();
49 if ( contents.length ) {
50 contents.wrapAll( html );
58 wrap: function( html ) {
59 var isFunction = jQuery.isFunction( html );
61 return this.each(function( i ) {
62 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
66 unwrap: function( selector ) {
67 this.parent( selector ).not( "body" ).each(function() {
68 jQuery( this ).replaceWith( this.childNodes );