@@ -2364,33 +2364,48 @@ QUnit.test( "clone() delegated events (#11076)", function( assert ) {
23642364 clone . remove ( ) ;
23652365} ) ;
23662366
2367- QUnit . test ( "checkbox state (#3827)" , function ( assert ) {
2368- assert . expect ( 9 ) ;
2367+ QUnit . test ( "checkbox state (#3827, gh-3423 )" , function ( assert ) {
2368+ assert . expect ( 17 ) ;
23692369
2370- var markup = jQuery ( "<div><input type=checkbox><div>" ) . appendTo ( "#qunit-fixture" ) ,
2371- cb = markup . find ( "input" ) [ 0 ] ;
2370+ var cbParent = jQuery ( "<div><input type=checkbox><div>" ) . appendTo ( "#qunit-fixture" ) ,
2371+ cb = cbParent . find ( "input" ) [ 0 ] ,
2372+ radioParent = jQuery (
2373+ "<div><input type=radio name=gh3423><input type=radio name=gh3423><div>"
2374+ ) . appendTo ( "#qunit-fixture" ) ,
2375+ radio = radioParent . find ( "input" ) [ 0 ] ,
2376+ radio2 = radioParent . find ( "input" ) [ 1 ] ;
23722377
23732378 jQuery ( cb ) . on ( "click" , function ( ) {
23742379 assert . equal ( this . checked , false , "just-clicked checkbox is not checked" ) ;
23752380 } ) ;
2376- markup . on ( "click" , function ( ) {
2381+ cbParent . on ( "click" , function ( ) {
23772382 assert . equal ( cb . checked , false , "checkbox is not checked in bubbled event" ) ;
23782383 } ) ;
2384+ radioParent . on ( "click" , function ( ) {
2385+ assert . equal ( radio . checked , false , "radio is not checked in bubbled event" ) ;
2386+ } ) ;
23792387
23802388 // Native click
2381- cb . checked = true ;
2389+ cb . checked = radio . checked = true ;
23822390 assert . equal ( cb . checked , true , "native - checkbox is initially checked" ) ;
2391+ assert . equal ( radio . checked , true , "native - radio is initially checked" ) ;
23832392 cb . click ( ) ;
2393+ radio2 . click ( ) ;
23842394 assert . equal ( cb . checked , false , "native - checkbox is no longer checked" ) ;
2395+ assert . equal ( radio . checked , false , "native - radio is no longer checked" ) ;
23852396
23862397 // jQuery click
2387- cb . checked = true ;
2388- assert . equal ( cb . checked , true , "jQuery - checkbox is initially checked" ) ;
2389- jQuery ( cb ) . trigger ( "click" ) ;
2390- assert . equal ( cb . checked , false , "jQuery - checkbox is no longer checked" ) ;
2398+ cb . checked = radio . checked = true ;
2399+ assert . equal ( cb . checked , true , ".trigger - checkbox is initially checked" ) ;
2400+ assert . equal ( radio . checked , true , ".trigger - radio is initially checked" ) ;
2401+ jQuery ( [ cb , radio2 ] ) . trigger ( "click" ) ;
2402+ assert . equal ( cb . checked , false , ".trigger - checkbox is no longer checked" ) ;
2403+ assert . equal ( radio . checked , false , ".trigger - radio is no longer checked" ) ;
23912404
23922405 // Handlers only; checkbox state remains false
2393- jQuery ( cb ) . triggerHandler ( "click" ) ;
2406+ jQuery ( [ cb , radio2 ] ) . triggerHandler ( "click" ) ;
2407+ assert . equal ( cb . checked , false , ".triggerHandler - checkbox is still unchecked" ) ;
2408+ assert . equal ( radio . checked , false , ".triggerHandler - radio is still unchecked" ) ;
23942409} ) ;
23952410
23962411QUnit . test ( "hover event no longer special since 1.9" , function ( assert ) {
0 commit comments