@ -100,6 +100,11 @@ export function check_element(node, context) {
}
}
}
}
const interactivity = element _interactivity ( node . name , attribute _map ) ;
const is _interactive = interactivity === ElementInteractivity . Interactive ;
const is _non _interactive = interactivity === ElementInteractivity . NonInteractive ;
const is _static = interactivity === ElementInteractivity . Static ;
for ( const attribute of node . attributes ) {
for ( const attribute of node . attributes ) {
if ( attribute . type !== 'Attribute' ) continue ;
if ( attribute . type !== 'Attribute' ) continue ;
@ -133,7 +138,7 @@ export function check_element(node, context) {
if (
if (
name === 'aria-activedescendant' &&
name === 'aria-activedescendant' &&
! is _dynamic _element &&
! is _dynamic _element &&
! is _interactive _element ( node . name , attribute _map ) &&
! is _interactive &&
! attribute _map . has ( 'tabindex' ) &&
! attribute _map . has ( 'tabindex' ) &&
! has _spread
! has _spread
) {
) {
@ -215,7 +220,7 @@ export function check_element(node, context) {
! is _hidden _from _screen _reader ( node . name , attribute _map ) &&
! is _hidden _from _screen _reader ( node . name , attribute _map ) &&
! is _presentation _role ( current _role ) &&
! is _presentation _role ( current _role ) &&
is _interactive _roles ( current _role ) &&
is _interactive _roles ( current _role ) &&
is _static _element ( node . name , attribute _map ) &&
is _static &&
! attribute _map . get ( 'tabindex' )
! attribute _map . get ( 'tabindex' )
) {
) {
const has _interactive _handlers = [ ... handlers ] . some ( ( handler ) =>
const has _interactive _handlers = [ ... handlers ] . some ( ( handler ) =>
@ -229,7 +234,7 @@ export function check_element(node, context) {
// no-interactive-element-to-noninteractive-role
// no-interactive-element-to-noninteractive-role
if (
if (
! has _spread &&
! has _spread &&
is _interactive _element ( node . name , attribute _map ) &&
is _interactive &&
( is _non _interactive _roles ( current _role ) || is _presentation _role ( current _role ) )
( is _non _interactive _roles ( current _role ) || is _presentation _role ( current _role ) )
) {
) {
w . a11y _no _interactive _element _to _noninteractive _role ( node , node . name , current _role ) ;
w . a11y _no _interactive _element _to _noninteractive _role ( node , node . name , current _role ) ;
@ -238,7 +243,7 @@ export function check_element(node, context) {
// no-noninteractive-element-to-interactive-role
// no-noninteractive-element-to-interactive-role
if (
if (
! has _spread &&
! has _spread &&
is _non _interactive _element ( node . name , attribute _map ) &&
is _non _interactive &&
is _interactive _roles ( current _role ) &&
is _interactive _roles ( current _role ) &&
! a11y _non _interactive _element _to _interactive _role _exceptions [ node . name ] ? . includes (
! a11y _non _interactive _element _to _interactive _role _exceptions [ node . name ] ? . includes (
current _role
current _role
@ -291,7 +296,7 @@ export function check_element(node, context) {
! is _dynamic _element &&
! is _dynamic _element &&
! is _hidden _from _screen _reader ( node . name , attribute _map ) &&
! is _hidden _from _screen _reader ( node . name , attribute _map ) &&
( ! role || is _non _presentation _role ) &&
( ! role || is _non _presentation _role ) &&
! is _interactive _element ( node . name , attribute _map ) &&
! is _interactive &&
! has _spread
! has _spread
) {
) {
const has _key _event =
const has _key _event =
@ -307,11 +312,7 @@ export function check_element(node, context) {
) ;
) ;
// no-noninteractive-tabindex
// no-noninteractive-tabindex
if (
if ( ! is _dynamic _element && ! is _interactive && ! is _interactive _roles ( role _static _value ) ) {
! is _dynamic _element &&
! is _interactive _element ( node . name , attribute _map ) &&
! is _interactive _roles ( role _static _value )
) {
const tab _index = attribute _map . get ( 'tabindex' ) ;
const tab _index = attribute _map . get ( 'tabindex' ) ;
const tab _index _value = get _static _text _value ( tab _index ) ;
const tab _index _value = get _static _text _value ( tab _index ) ;
if ( tab _index && ( tab _index _value === null || Number ( tab _index _value ) >= 0 ) ) {
if ( tab _index && ( tab _index _value === null || Number ( tab _index _value ) >= 0 ) ) {
@ -341,9 +342,8 @@ export function check_element(node, context) {
! has _contenteditable _attr &&
! has _contenteditable _attr &&
! is _hidden _from _screen _reader ( node . name , attribute _map ) &&
! is _hidden _from _screen _reader ( node . name , attribute _map ) &&
! is _presentation _role ( role _static _value ) &&
! is _presentation _role ( role _static _value ) &&
( ( ! is _interactive _element ( node . name , attribute _map ) &&
( ( ! is _interactive && is _non _interactive _roles ( role _static _value ) ) ||
is _non _interactive _roles ( role _static _value ) ) ||
( is _non _interactive && ! role ) )
( is _non _interactive _element ( node . name , attribute _map ) && ! role ) )
) {
) {
const has _interactive _handlers = [ ... handlers ] . some ( ( handler ) =>
const has _interactive _handlers = [ ... handlers ] . some ( ( handler ) =>
a11y _recommended _interactive _handlers . includes ( handler )
a11y _recommended _interactive _handlers . includes ( handler )
@ -359,9 +359,9 @@ export function check_element(node, context) {
( ! role || role _static _value !== null ) &&
( ! role || role _static _value !== null ) &&
! is _hidden _from _screen _reader ( node . name , attribute _map ) &&
! is _hidden _from _screen _reader ( node . name , attribute _map ) &&
! is _presentation _role ( role _static _value ) &&
! is _presentation _role ( role _static _value ) &&
! is _interactive _element ( node . name , attribute _map ) &&
! is _interactive &&
! is _interactive _roles ( role _static _value ) &&
! is _interactive _roles ( role _static _value ) &&
! is _non _interactive _element ( node . name , attribute _map ) &&
! is _non _interactive &&
! is _non _interactive _roles ( role _static _value ) &&
! is _non _interactive _roles ( role _static _value ) &&
! is _abstract _role ( role _static _value )
! is _abstract _role ( role _static _value )
) {
) {
@ -643,33 +643,6 @@ function element_interactivity(tag_name, attribute_map) {
return ElementInteractivity . Static ;
return ElementInteractivity . Static ;
}
}
/ * *
* @ param { string } tag _name
* @ param { Map < string , AST . Attribute > } attribute _map
* @ returns { boolean }
* /
function is _interactive _element ( tag _name , attribute _map ) {
return element _interactivity ( tag _name , attribute _map ) === ElementInteractivity . Interactive ;
}
/ * *
* @ param { string } tag _name
* @ param { Map < string , AST . Attribute > } attribute _map
* @ returns { boolean }
* /
function is _non _interactive _element ( tag _name , attribute _map ) {
return element _interactivity ( tag _name , attribute _map ) === ElementInteractivity . NonInteractive ;
}
/ * *
* @ param { string } tag _name
* @ param { Map < string , AST . Attribute > } attribute _map
* @ returns { boolean }
* /
function is _static _element ( tag _name , attribute _map ) {
return element _interactivity ( tag _name , attribute _map ) === ElementInteractivity . Static ;
}
/ * *
/ * *
* @ param { ARIARoleDefinitionKey } role
* @ param { ARIARoleDefinitionKey } role
* @ param { string } tag _name
* @ param { string } tag _name