fix without the extra check

pull/17990/head
razinshafayet 6 months ago committed by Razin Shafayet
parent 1fa151fdde
commit d81342a213

@ -292,12 +292,11 @@ export function check_element(node, context) {
if (handlers.has('click')) { if (handlers.has('click')) {
const is_non_presentation_role = const is_non_presentation_role =
role_static_value !== null && !is_presentation_role(role_static_value); role_static_value !== null && !is_presentation_role(role_static_value);
const is_table_cell_or_row = node.name === 'tr' || node.name === 'td' || node.name === 'th';
if ( if (
!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 || is_table_cell_or_row) && !is_interactive &&
!has_spread !has_spread
) { ) {
const has_key_event = const has_key_event =
@ -614,6 +613,12 @@ function has_disabled_attribute(attribute_map) {
* @returns {typeof ElementInteractivity[keyof typeof ElementInteractivity]} * @returns {typeof ElementInteractivity[keyof typeof ElementInteractivity]}
*/ */
function element_interactivity(tag_name, attribute_map) { function element_interactivity(tag_name, attribute_map) {
if (tag_name === 'tr' || tag_name === 'td' || tag_name === 'th') {
return attribute_map.has('role')
? ElementInteractivity.Static
: ElementInteractivity.NonInteractive;
}
if ( if (
interactive_element_role_schemas.some((schema) => match_schema(schema, tag_name, attribute_map)) interactive_element_role_schemas.some((schema) => match_schema(schema, tag_name, attribute_map))
) { ) {

@ -26,8 +26,11 @@
<footer on:click={noop}></footer> <footer on:click={noop}></footer>
<!-- svelte-ignore a11y_no_noninteractive_element_interactions --> <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<footer on:click={noop}></footer> <footer on:click={noop}></footer>
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<tr on:click={noop}></tr> <tr on:click={noop}></tr>
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<td on:click={noop}></td> <td on:click={noop}></td>
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<th on:click={noop}></th> <th on:click={noop}></th>
<!-- should not warn --> <!-- should not warn -->

@ -99,11 +99,11 @@
"code": "a11y_click_events_have_key_events", "code": "a11y_click_events_have_key_events",
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate", "message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate",
"start": { "start": {
"line": 29, "line": 30,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 29, "line": 30,
"column": 25 "column": 25
} }
}, },
@ -111,11 +111,11 @@
"code": "a11y_click_events_have_key_events", "code": "a11y_click_events_have_key_events",
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate", "message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate",
"start": { "start": {
"line": 30, "line": 32,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 30, "line": 32,
"column": 25 "column": 25
} }
}, },
@ -123,11 +123,11 @@
"code": "a11y_click_events_have_key_events", "code": "a11y_click_events_have_key_events",
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate", "message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate",
"start": { "start": {
"line": 31, "line": 34,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 31, "line": 34,
"column": 25 "column": 25
} }
} }

@ -683,18 +683,6 @@
"line": 146 "line": 146
} }
}, },
{
"code": "a11y_no_interactive_element_to_noninteractive_role",
"end": {
"column": 25,
"line": 147
},
"message": "`<tr>` cannot have role 'listitem'",
"start": {
"column": 0,
"line": 147
}
},
{ {
"code": "a11y_no_interactive_element_to_noninteractive_role", "code": "a11y_no_interactive_element_to_noninteractive_role",
"end": { "end": {

Loading…
Cancel
Save