X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmanipulation.js;h=742ec254336bbdb583bd1aee5a82755398f46710;hb=c320e4f3c2174148e5c13276237abb01547d52f5;hp=9ed22baaf848ba2451fbf59e165828af6e189d8a;hpb=8fa9e9d6d0307a5af8d7478d6e030af5afabba9e;p=jquery.git diff --git a/src/manipulation.js b/src/manipulation.js index 9ed22ba..742ec25 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -77,7 +77,14 @@ jQuery.fn.extend({ wrapInner: function( html ) { return this.each(function() { - jQuery( this ).contents().wrapAll( html ); + var self = jQuery( this ), contents = self.contents(); + + if ( contents.length ) { + contents.wrapAll( html ); + + } else { + self.append( html ); + } }); }, @@ -213,6 +220,12 @@ jQuery.fn.extend({ replaceWith: function( value ) { if ( this[0] && this[0].parentNode ) { + // Make sure that the elements are removed from the DOM before they are inserted + // this can help fix replacing a parent with child elements + if ( !jQuery.isFunction( value ) ) { + value = jQuery( value ).detach(); + } + return this.each(function() { var next = this.nextSibling, parent = this.parentNode;