]> source.dussan.org Git - jquery.git/commitdiff
Revert "Fix #12120. Always stack .before/.after, and fix disconnected nodes."
authorDave Methvin <dave.methvin@gmail.com>
Fri, 24 Aug 2012 15:57:48 +0000 (11:57 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Fri, 24 Aug 2012 15:57:48 +0000 (11:57 -0400)
This reverts commit e2eac3f4d2e7f47b67635704df8e3b6675a91ed6.

There is a 1.7 regression with isDisconnected() that we should fix before tackling this.

src/manipulation.js
test/unit/manipulation.js

index 67c6c06f0a82d7c8a2dea646f5147d4510b124e3..f87e3ca94b309cbdc4310b21a6e3ee1b72df9295 100644 (file)
@@ -148,7 +148,10 @@ jQuery.fn.extend({
                        });
                }
 
-               return this.pushStack( jQuery.merge( jQuery.clean( arguments ), this ), "before", this.selector );
+               if ( arguments.length ) {
+                       var set = jQuery.clean( arguments );
+                       return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
+               }
        },
 
        after: function() {
@@ -158,7 +161,10 @@ jQuery.fn.extend({
                        });
                }
 
-               return this.pushStack( jQuery.merge( this.toArray(), jQuery.clean( arguments ) ), "after", this.selector );
+               if ( arguments.length ) {
+                       var set = jQuery.clean( arguments );
+                       return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
+               }
        },
 
        // keepData is for internal use only--do not document
@@ -715,7 +721,6 @@ jQuery.extend({
 
                // Fix #11356: Clear elements from safeFragment
                if ( div ) {
-                       div.innerHTML = "";
                        safe.removeChild( div );
                        elem = div = safe = null;
                }
index 15a95864d8ff1b6d9e4b3ae26a0ebf6857eb9e5e..d63b3ff86b7a9b12088bb07baaf987585f97ecde 100644 (file)
@@ -909,13 +909,12 @@ test("before(Function)", function() {
        testBefore(manipulationFunctionReturningObj);
 });
 
-test("before and after w/ empty object (#10812, #12120)", function() {
-       expect(3);
+test("before and after w/ empty object (#10812)", function() {
+       expect(2);
 
-       var res = jQuery("#notInTheDocument").before("<span>(</span>").after("<span>)</span>");
-       equal( res.length, 2, "added two elements to the empty object" );
-       equal( res.text(), "()", "correctly appended text" );
-       equal( res.end().text(), "(", "stacked the previous value" );
+       var res = jQuery( "#notInTheDocument" ).before( "(" ).after( ")" );
+       equal( res.length, 2, "didn't choke on empty object" );
+       equal( res.wrapAll("<div/>").parent().text(), "()", "correctly appended text" );
 });
 
 test("before and after on disconnected node (#10517)", function() {