From: Oleg Gaidarenko Date: Fri, 13 Nov 2015 12:27:35 +0000 (+0300) Subject: Revert "Wrap: Support .unwrap( selector) for selective unwrapping" X-Git-Tag: 2.2.0~45 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f66490412a794eea7530fe3236aae45bdd72b720;p=jquery.git Revert "Wrap: Support .unwrap( selector) for selective unwrapping" This reverts commit 7b09235ceed57bbcc26fc2c76147eb4e95ebdb92. --- diff --git a/src/wrap.js b/src/wrap.js index 69c7cbf23..c85cd304e 100644 --- a/src/wrap.js +++ b/src/wrap.js @@ -63,11 +63,12 @@ jQuery.fn.extend( { } ); }, - unwrap: function( selector ) { - this.parent( selector ).not( "body" ).each( function() { - jQuery( this ).replaceWith( this.childNodes ); - } ); - return this; + unwrap: function() { + return this.parent().each(function() { + if ( !jQuery.nodeName( this, "body" ) ) { + jQuery( this ).replaceWith( this.childNodes ); + } + }).end(); } } ); diff --git a/test/unit/wrap.js b/test/unit/wrap.js index 80abd9e87..d7ba80d17 100644 --- a/test/unit/wrap.js +++ b/test/unit/wrap.js @@ -9,7 +9,7 @@ QUnit.module( "wrap", { } ); // See test/unit/manipulation.js for explanation about these 2 functions -function manipulationBareObj( value ) { +function manipulationBareObj( value ) { return value; } @@ -455,48 +455,6 @@ QUnit.test( "unwrap()", function( assert ) { jQuery( "body > span.unwrap" ).remove(); } ); -QUnit.test( "unwrap( selector )", function( assert ) { - - assert.expect( 5 ); - - jQuery( "body" ).append( - " " - ); - - // Shouldn't unwrap, no match - jQuery( "#unwrap1 span" ) .unwrap( "#unwrap2" ); - assert.equal( - jQuery( "#unwrap1" ).length, 1, "still wrapped" - ); - - // Shouldn't unwrap, no match - jQuery( "#unwrap1 span" ) .unwrap( "span" ); - assert.equal( - jQuery( "#unwrap1" ).length, 1, "still wrapped" - ); - - // Unwraps - jQuery( "#unwrap1 span" ) .unwrap( "#unwrap1" ); - assert.equal( - jQuery( "#unwrap1" ).length, 0, "unwrapped match" - ); - - // Check return values - assert.deepEqual( - jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "quote" ).get(), - "return on unmatched unwrap" - ); - assert.deepEqual( - jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "#unwrap2" ).get(), - "return on matched unwrap" - ); - - jQuery( "body > span.unwrap" ).remove(); -} ); - QUnit.test( "jQuery() & wrap[Inner/All]() handle unknown elems (#10667)", function( assert ) { assert.expect( 2 );