]> source.dussan.org Git - jquery.git/commitdiff
Make sure we use detach instead of remove in replaceWith. Fixes #5785.
authorjeresig <jeresig@gmail.com>
Mon, 11 Jan 2010 20:57:45 +0000 (15:57 -0500)
committerjeresig <jeresig@gmail.com>
Mon, 11 Jan 2010 20:57:45 +0000 (15:57 -0500)
src/manipulation.js
test/unit/manipulation.js

index 9ed22baaf848ba2451fbf59e165828af6e189d8a..f2f6c7de6d37d2ba7ea2399e0b1420e437b8b327 100644 (file)
@@ -216,7 +216,7 @@ jQuery.fn.extend({
                        return this.each(function() {
                                var next = this.nextSibling, parent = this.parentNode;
 
-                               jQuery(this).remove();
+                               jQuery(this).detach();
 
                                if ( next ) {
                                        jQuery(next).before( value );
index a7e1f7e4548e0a145314ac6c9a479f28ccdb93d0..52becfefb37a5a7281da1147df2362ab06476d4b 100644 (file)
@@ -626,7 +626,7 @@ test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() {
 });
 
 var testReplaceWith = function(val) {
-       expect(14);
+       expect(16);
        jQuery('#yahoo').replaceWith(val( '<b id="replace">buga</b>' ));
        ok( jQuery("#replace")[0], 'Replace element with string' );
        ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
@@ -648,6 +648,15 @@ var testReplaceWith = function(val) {
        ok( jQuery("#mark")[0], 'Replace element with set of elements' );
        ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
 
+       reset();
+       var tmp = jQuery("<div/>").appendTo("body").click(function(){ ok(true, "Newly bound click run." ); });
+       var y = jQuery('#yahoo').click(function(){ ok(true, "Previously bound click run." ); });
+       y.replaceWith( tmp );
+       tmp.click();
+       y.click();
+
+       reset();
+
        var set = jQuery("<div/>").replaceWith(val("<span>test</span>"));
        equals( set[0].nodeName.toLowerCase(), "span", "Replace the disconnected node." );
        equals( set.length, 1, "Replace the disconnected node." );