4 "./manipulation", // clone
5 "./traversing" // parent, contents
6 ], function( jQuery
) {
9 wrapAll: function( html
) {
10 if ( jQuery
.isFunction( html
) ) {
11 return this.each(function(i
) {
12 jQuery(this).wrapAll( html
.call(this, i
) );
17 // The elements to wrap the target around
18 var wrap
= jQuery( html
, this[0].ownerDocument
).eq(0).clone(true);
20 if ( this[0].parentNode
) {
21 wrap
.insertBefore( this[0] );
27 while ( elem
.firstChild
&& elem
.firstChild
.nodeType
=== 1 ) {
28 elem
= elem
.firstChild
;
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
);
67 return this.parent().each(function() {
68 if ( !jQuery
.nodeName( this, "body" ) ) {
69 jQuery( this ).replaceWith( this.childNodes
);