@@ -416,6 +416,51 @@ QUnit.module('Aria accessibility', {
416416 assert . strictEqual ( $radioContainer . attr ( 'aria-labelledby' ) , itemId , `item[${ index } ] radio container aria-labelledby references item element id` ) ;
417417 } ) ;
418418 } ) ;
419+
420+ QUnit . test ( 'Item with html: role="radio" is set on item element, no radio container created' , function ( assert ) {
421+ helper . createWidget ( {
422+ items : [
423+ { html : '<span>Option A</span>' } ,
424+ { html : '<span>Option B</span>' } ,
425+ ] ,
426+ } ) ;
427+
428+ helper . checkAttributes ( helper . $widget , { role : 'radiogroup' , tabindex : '0' } , 'widget' ) ;
429+
430+ helper . getItems ( ) . each ( ( index , item ) => {
431+ const $item = $ ( item ) ;
432+ const $radioContainer = $item . find ( `.${ RADIO_VALUE_CONTAINER_CLASS } ` ) ;
433+
434+ assert . strictEqual ( $radioContainer . length , 0 , `item[${ index } ] has no radio container when html is provided` ) ;
435+ assert . strictEqual ( $item . attr ( 'role' ) , 'radio' , `item[${ index } ] element itself has role="radio"` ) ;
436+ assert . strictEqual ( $item . attr ( 'aria-checked' ) , 'false' , `item[${ index } ] element has aria-checked="false" by default` ) ;
437+ assert . strictEqual ( $item . attr ( 'aria-labelledby' ) , undefined , `item[${ index } ] element has no aria-labelledby when html is provided` ) ;
438+ } ) ;
439+ } ) ;
440+
441+ QUnit . test ( 'Item with html: aria-checked on item element is updated on value change' , function ( assert ) {
442+ const items = [
443+ { html : '<span>Option A</span>' , value : 'a' } ,
444+ { html : '<span>Option B</span>' , value : 'b' } ,
445+ ] ;
446+ helper . createWidget ( { items, valueExpr : 'value' , value : 'a' } ) ;
447+
448+ helper . getItems ( ) . each ( ( index , item ) => {
449+ const $item = $ ( item ) ;
450+ const expected = index === 0 ? 'true' : 'false' ;
451+
452+ assert . strictEqual ( $item . attr ( 'aria-checked' ) , expected , `item[${ index } ] has correct aria-checked after initial render` ) ;
453+ } ) ;
454+
455+ helper . widget . option ( 'value' , 'b' ) ;
456+
457+ helper . getItems ( ) . each ( ( index , item ) => {
458+ const $item = $ ( item ) ;
459+ const expected = index === 1 ? 'true' : 'false' ;
460+
461+ assert . strictEqual ( $item . attr ( 'aria-checked' ) , expected , `item[${ index } ] has correct aria-checked after value change` ) ;
462+ } ) ;
463+ } ) ;
419464} ) ;
420465
421466module ( 'layout' , moduleConfig , ( ) => {
0 commit comments