} );
},
- 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();
}
} );
} );
// See test/unit/manipulation.js for explanation about these 2 functions
-function manipulationBareObj( value ) {
+function manipulationBareObj( value ) {
return value;
}
jQuery( "body > span.unwrap" ).remove();
} );
-QUnit.test( "unwrap( selector )", function( assert ) {
-
- assert.expect( 5 );
-
- jQuery( "body" ).append(
- " <div id='unwrap' style='display: none;'> <div id='unwrap1'>" +
- "<span class='unwrap'>a</span> <span class='unwrap'>b</span> </div>" +
- " <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span>" +
- " </div> </div>"
- );
-
- // 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(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", function( assert ) {
assert.expect( 2 );