@@ 5884-5916 (lines=33) @@ | ||
5881 | return this; |
|
5882 | }, |
|
5883 | ||
5884 | replaceWith: function( value ) { |
|
5885 | if ( this[0] && this[0].parentNode ) { |
|
5886 | // Make sure that the elements are removed from the DOM before they are inserted |
|
5887 | // this can help fix replacing a parent with child elements |
|
5888 | if ( jQuery.isFunction( value ) ) { |
|
5889 | return this.each(function(i) { |
|
5890 | var self = jQuery(this), old = self.html(); |
|
5891 | self.replaceWith( value.call( this, i, old ) ); |
|
5892 | }); |
|
5893 | } |
|
5894 | ||
5895 | if ( typeof value !== "string" ) { |
|
5896 | value = jQuery( value ).detach(); |
|
5897 | } |
|
5898 | ||
5899 | return this.each(function() { |
|
5900 | var next = this.nextSibling, |
|
5901 | parent = this.parentNode; |
|
5902 | ||
5903 | jQuery( this ).remove(); |
|
5904 | ||
5905 | if ( next ) { |
|
5906 | jQuery(next).before( value ); |
|
5907 | } else { |
|
5908 | jQuery(parent).append( value ); |
|
5909 | } |
|
5910 | }); |
|
5911 | } else { |
|
5912 | return this.length ? |
|
5913 | this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : |
|
5914 | this; |
|
5915 | } |
|
5916 | }, |
|
5917 | ||
5918 | detach: function( selector ) { |
|
5919 | return this.remove( selector, true ); |
@@ 5188-5218 (lines=31) @@ | ||
5185 | return this; |
|
5186 | }, |
|
5187 | ||
5188 | replaceWith: function( value ) { |
|
5189 | if ( this[0] && this[0].parentNode ) { |
|
5190 | // Make sure that the elements are removed from the DOM before they are inserted |
|
5191 | // this can help fix replacing a parent with child elements |
|
5192 | if ( jQuery.isFunction( value ) ) { |
|
5193 | return this.each(function(i) { |
|
5194 | var self = jQuery(this), old = self.html(); |
|
5195 | self.replaceWith( value.call( this, i, old ) ); |
|
5196 | }); |
|
5197 | } |
|
5198 | ||
5199 | if ( typeof value !== "string" ) { |
|
5200 | value = jQuery( value ).detach(); |
|
5201 | } |
|
5202 | ||
5203 | return this.each(function() { |
|
5204 | var next = this.nextSibling, |
|
5205 | parent = this.parentNode; |
|
5206 | ||
5207 | jQuery( this ).remove(); |
|
5208 | ||
5209 | if ( next ) { |
|
5210 | jQuery(next).before( value ); |
|
5211 | } else { |
|
5212 | jQuery(parent).append( value ); |
|
5213 | } |
|
5214 | }); |
|
5215 | } else { |
|
5216 | return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); |
|
5217 | } |
|
5218 | }, |
|
5219 | ||
5220 | detach: function( selector ) { |
|
5221 | return this.remove( selector, true ); |