@@ -332,46 +332,90 @@ QUnit.test( "wrapInner(Function) returns Element", function( assert ) {
332332
333333 var num ,
334334 val = manipulationFunctionReturningObj ,
335- div = jQuery ( "<div/>" ) ;
335+ div = jQuery ( "<div/>" ) ;
336336
337- num = jQuery ( "#first" ) . children ( ) . length ;
338- jQuery ( "#first" ) . wrapInner ( val ( document . getElementById ( "empty" ) ) ) ;
339- equal ( jQuery ( "#first" ) . children ( ) . length , 1 , "Only one child" ) ;
340- ok ( jQuery ( "#first" ) . children ( ) . is ( "#empty" ) , "Verify Right Element" ) ;
341- equal ( jQuery ( "#first" ) . children ( ) . children ( ) . length , num , "Verify Elements Intact" ) ;
337+ num = jQuery ( "#first" ) . children ( ) . length ;
338+ jQuery ( "#first" ) . wrapInner ( val ( document . getElementById ( "empty" ) ) ) ;
339+ equal ( jQuery ( "#first" ) . children ( ) . length , 1 , "Only one child" ) ;
340+ ok ( jQuery ( "#first" ) . children ( ) . is ( "#empty" ) , "Verify Right Element" ) ;
341+ equal ( jQuery ( "#first" ) . children ( ) . children ( ) . length , num , "Verify Elements Intact" ) ;
342342
343- div . wrapInner ( val ( "<span></span>" ) ) ;
343+ div . wrapInner ( val ( "<span></span>" ) ) ;
344344 equal ( div . children ( ) . length , 1 , "The contents were wrapped." ) ;
345345 equal ( div . children ( ) [ 0 ] . nodeName . toLowerCase ( ) , "span" , "A span was inserted." ) ;
346- } ) ;
346+ } ) ;
347347
348348test ( "unwrap()" , function ( ) {
349349
350350 expect ( 9 ) ;
351351
352- 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 id='unwrap3'> <b><span class='unwrap unwrap3'>e</span></b> <b><span class='unwrap unwrap3'>f</span></b> </div> </div>" ) ;
352+ jQuery ( "body" ) . append (
353+ " <div id='unwrap' style='display: none;'> <div id='unwrap1'>" +
354+ " <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'>" +
355+ " <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> <div id='unwrap3'>" +
356+ " <b><span class='unwrap unwrap3'>e</span></b>" +
357+ " <b><span class='unwrap unwrap3'>f</span></b> </div> </div>"
358+ ) ;
353359
354- var abcd = jQuery ( "#unwrap1 > span, #unwrap2 > span" ) . get ( ) ,
355- abcdef = jQuery ( "#unwrap span" ) . get ( ) ;
360+ var abcd = jQuery ( "#unwrap1 > span, #unwrap2 > span" ) . get ( ) ,
361+ abcdef = jQuery ( "#unwrap span" ) . get ( ) ;
356362
357- equal ( jQuery ( "#unwrap1 span" ) . add ( "#unwrap2 span:first-child" ) . unwrap ( ) . length , 3 , "make #unwrap1 and #unwrap2 go away" ) ;
358- deepEqual ( jQuery ( "#unwrap > span" ) . get ( ) , abcd , "all four spans should still exist" ) ;
363+ equal (
364+ jQuery ( "#unwrap1 span" ) . add ( "#unwrap2 span:first-child" ) . unwrap ( ) . length ,
365+ 3 ,
366+ "make #unwrap1 and #unwrap2 go away"
367+ ) ;
359368
360- deepEqual ( jQuery ( "#unwrap3 span" ) . unwrap ( ) . get ( ) , jQuery ( "#unwrap3 > span" ) . get ( ) , "make all b in #unwrap3 go away" ) ;
369+ deepEqual (
370+ jQuery ( "#unwrap > span" ) . get ( ) ,
371+ abcd ,
372+ "all four spans should still exist"
373+ ) ;
361374
362- deepEqual ( jQuery ( "#unwrap3 span" ) . unwrap ( ) . get ( ) , jQuery ( "#unwrap > span.unwrap3" ) . get ( ) , "make #unwrap3 go away" ) ;
375+ deepEqual (
376+ jQuery ( "#unwrap3 span" ) . unwrap ( ) . get ( ) ,
377+ jQuery ( "#unwrap3 > span" ) . get ( ) ,
378+ "make all b in #unwrap3 go away"
379+ ) ;
363380
364- deepEqual ( jQuery ( "#unwrap" ) . children ( ) . get ( ) , abcdef , "#unwrap only contains 6 child spans" ) ;
381+ deepEqual (
382+ jQuery ( "#unwrap3 span" ) . unwrap ( ) . get ( ) ,
383+ jQuery ( "#unwrap > span.unwrap3" ) . get ( ) ,
384+ "make #unwrap3 go away"
385+ ) ;
365386
366- deepEqual ( jQuery ( "#unwrap > span" ) . unwrap ( ) . get ( ) , jQuery ( "body > span.unwrap" ) . get ( ) , "make the 6 spans become children of body" ) ;
387+ deepEqual (
388+ jQuery ( "#unwrap" ) . children ( ) . get ( ) ,
389+ abcdef ,
390+ "#unwrap only contains 6 child spans"
391+ ) ;
367392
368- deepEqual ( jQuery ( "body > span.unwrap" ) . unwrap ( ) . get ( ) , jQuery ( "body > span.unwrap" ) . get ( ) , "can't unwrap children of body" ) ;
369- deepEqual ( jQuery ( "body > span.unwrap" ) . unwrap ( ) . get ( ) , abcdef , "can't unwrap children of body" ) ;
393+ deepEqual (
394+ jQuery ( "#unwrap > span" ) . unwrap ( ) . get ( ) ,
395+ jQuery ( "body > span.unwrap" ) . get ( ) ,
396+ "make the 6 spans become children of body"
397+ ) ;
398+
399+ deepEqual (
400+ jQuery ( "body > span.unwrap" ) . unwrap ( ) . get ( ) ,
401+ jQuery ( "body > span.unwrap" ) . get ( ) ,
402+ "can't unwrap children of body"
403+ ) ;
370404
371- deepEqual ( jQuery ( "body > span.unwrap" ) . get ( ) , abcdef , "body contains 6 .unwrap child spans" ) ;
405+ deepEqual (
406+ jQuery ( "body > span.unwrap" ) . unwrap ( ) . get ( ) ,
407+ abcdef ,
408+ "can't unwrap children of body"
409+ ) ;
372410
373- jQuery ( "body > span.unwrap" ) . remove ( ) ;
374- } ) ;
411+ deepEqual (
412+ jQuery ( "body > span.unwrap" ) . get ( ) ,
413+ abcdef ,
414+ "body contains 6 .unwrap child spans"
415+ ) ;
416+
417+ jQuery ( "body > span.unwrap" ) . remove ( ) ;
418+ } ) ;
375419
376420QUnit . test ( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)" , function ( assert ) {
377421
0 commit comments