@@ -332,136 +332,46 @@ 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- assert . equal (
340- jQuery ( "#first" ) . children ( ) . length , 1 , "Only one child"
341- ) ;
342- assert . ok (
343- jQuery ( "#first" ) . children ( ) . is ( "#empty" ) , "Verify Right Element"
344- ) ;
345- assert . equal (
346- jQuery ( "#first" ) . children ( ) . children ( ) . length , num , "Verify Elements Intact"
347- ) ;
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" ) ;
348342
349- div . wrapInner ( val ( "<span></span>" ) ) ;
350- assert . equal (
351- div . children ( ) . length , 1 , "The contents were wrapped."
352- ) ;
353- assert . equal (
354- div . children ( ) [ 0 ] . nodeName . toLowerCase ( ) , "span" , "A span was inserted."
355- ) ;
356- } ) ;
343+ div . wrapInner ( val ( "<span></span>" ) ) ;
344+ equal ( div . children ( ) . length , 1 , "The contents were wrapped." ) ;
345+ equal ( div . children ( ) [ 0 ] . nodeName . toLowerCase ( ) , "span" , "A span was inserted." ) ;
346+ } ) ;
357347
358- QUnit . test ( "unwrap()" , function ( assert ) {
348+ test ( "unwrap()" , function ( ) {
359349
360- assert . expect ( 9 ) ;
350+ expect ( 9 ) ;
361351
362- jQuery ( "body" ) . append (
363- " <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>" +
364- "a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'>" +
365- " <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div>" +
366- " <div id='unwrap3'> <b><span class='unwrap unwrap3'>e</span></b> " +
367- "<b><span class='unwrap unwrap3'>f</span></b> </div> </div>"
368- ) ;
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>" ) ;
369353
370- var abcd = jQuery ( "#unwrap1 > span, #unwrap2 > span" ) . get ( ) ,
371- abcdef = jQuery ( "#unwrap span" ) . get ( ) ;
354+ var abcd = jQuery ( "#unwrap1 > span, #unwrap2 > span" ) . get ( ) ,
355+ abcdef = jQuery ( "#unwrap span" ) . get ( ) ;
372356
373- assert . equal (
374- jQuery ( "#unwrap1 span" ) . add ( "#unwrap2 span:first-child" ) . unwrap ( ) . length ,
375- 3 ,
376- "make #unwrap1 and #unwrap2 go away"
377- ) ;
378- assert . deepEqual (
379- jQuery ( "#unwrap > span" ) . get ( ) , abcd , "all four spans should still exist"
380- ) ;
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" ) ;
381359
382- assert . deepEqual (
383- jQuery ( "#unwrap3 span" ) . unwrap ( ) . get ( ) ,
384- jQuery ( "#unwrap3 > span" ) . get ( ) ,
385- "make all b in #unwrap3 go away"
386- ) ;
360+ deepEqual ( jQuery ( "#unwrap3 span" ) . unwrap ( ) . get ( ) , jQuery ( "#unwrap3 > span" ) . get ( ) , "make all b in #unwrap3 go away" ) ;
387361
388- assert . deepEqual (
389- jQuery ( "#unwrap3 span" ) . unwrap ( ) . get ( ) ,
390- jQuery ( "#unwrap > span.unwrap3" ) . get ( ) ,
391- "make #unwrap3 go away"
392- ) ;
362+ deepEqual ( jQuery ( "#unwrap3 span" ) . unwrap ( ) . get ( ) , jQuery ( "#unwrap > span.unwrap3" ) . get ( ) , "make #unwrap3 go away" ) ;
393363
394- assert . deepEqual (
395- jQuery ( "#unwrap" ) . children ( ) . get ( ) ,
396- abcdef ,
397- "#unwrap only contains 6 child spans"
398- ) ;
364+ deepEqual ( jQuery ( "#unwrap" ) . children ( ) . get ( ) , abcdef , "#unwrap only contains 6 child spans" ) ;
399365
400- assert . deepEqual (
401- jQuery ( "#unwrap > span" ) . unwrap ( ) . get ( ) ,
402- jQuery ( "body > span.unwrap" ) . get ( ) ,
403- "make the 6 spans become children of body"
404- ) ;
405-
406- assert . deepEqual (
407- jQuery ( "body > span.unwrap" ) . unwrap ( ) . get ( ) ,
408- jQuery ( "body > span.unwrap" ) . get ( ) ,
409- "can't unwrap children of body"
410- ) ;
411- assert . deepEqual (
412- jQuery ( "body > span.unwrap" ) . unwrap ( ) . get ( ) , abcdef , "can't unwrap children of body"
413- ) ;
414-
415- assert . deepEqual (
416- jQuery ( "body > span.unwrap" ) . get ( ) , abcdef , "body contains 6 .unwrap child spans"
417- ) ;
418-
419- jQuery ( "body > span.unwrap" ) . remove ( ) ;
420- } ) ;
421-
422- QUnit . test ( "unwrap( selector )" , function ( assert ) {
423-
424- assert . expect ( 5 ) ;
425-
426- jQuery ( "body" ) . append (
427- " <div id='unwrap' style='display: none;'> <div id='unwrap1'>" +
428- " <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div>" +
429- " <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span>" +
430- " </div> </div>"
431- ) ;
432-
433- // Shouldn't unwrap, no match
434- jQuery ( "#unwrap1 span" ) . unwrap ( "#unwrap2" ) ;
435- assert . equal (
436- jQuery ( "#unwrap1" ) . length , 1 , "still wrapped"
437- ) ;
438-
439- // Shouldn't unwrap, no match
440- jQuery ( "#unwrap1 span" ) . unwrap ( "span" ) ;
441- assert . equal (
442- jQuery ( "#unwrap1" ) . length , 1 , "still wrapped"
443- ) ;
366+ deepEqual ( jQuery ( "#unwrap > span" ) . unwrap ( ) . get ( ) , jQuery ( "body > span.unwrap" ) . get ( ) , "make the 6 spans become children of body" ) ;
444367
445- // Unwraps
446- jQuery ( "#unwrap1 span" ) . unwrap ( "#unwrap1" ) ;
447- assert . equal (
448- jQuery ( "#unwrap1" ) . length , 0 , "unwrapped match"
449- ) ;
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" ) ;
450370
451- // Check return values
452- assert . deepEqual (
453- jQuery ( "#unwrap2 span" ) . get ( ) ,
454- jQuery ( "#unwrap2 span" ) . unwrap ( "quote" ) . get ( ) ,
455- "return on unmatched unwrap"
456- ) ;
457- assert . deepEqual (
458- jQuery ( "#unwrap2 span" ) . get ( ) ,
459- jQuery ( "#unwrap2 span" ) . unwrap ( "#unwrap2" ) . get ( ) ,
460- "return on matched unwrap"
461- ) ;
371+ deepEqual ( jQuery ( "body > span.unwrap" ) . get ( ) , abcdef , "body contains 6 .unwrap child spans" ) ;
462372
463- jQuery ( "body > span.unwrap" ) . remove ( ) ;
464- } ) ;
373+ jQuery ( "body > span.unwrap" ) . remove ( ) ;
374+ } ) ;
465375
466376QUnit . test ( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)" , function ( assert ) {
467377
0 commit comments