pull/17990/merge
Razin Shafayet 6 days ago committed by GitHub
commit f58fbd5cf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: warn on click handlers for table row and cell elements

@ -613,6 +613,12 @@ function has_disabled_attribute(attribute_map) {
* @returns {typeof ElementInteractivity[keyof typeof ElementInteractivity]}
*/
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 (
interactive_element_role_schemas.some((schema) => match_schema(schema, tag_name, attribute_map))
) {

@ -26,6 +26,12 @@
<footer on:click={noop}></footer>
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<footer on:click={noop}></footer>
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<tr on:click={noop}></tr>
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<td on:click={noop}></td>
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<th on:click={noop}></th>
<!-- should not warn -->
<div class="foo"></div>

@ -94,5 +94,41 @@
"line": 28,
"column": 33
}
},
{
"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",
"start": {
"line": 30,
"column": 0
},
"end": {
"line": 30,
"column": 25
}
},
{
"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",
"start": {
"line": 32,
"column": 0
},
"end": {
"line": 32,
"column": 25
}
},
{
"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",
"start": {
"line": 34,
"column": 0
},
"end": {
"line": 34,
"column": 25
}
}
]

@ -683,18 +683,6 @@
"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",
"end": {

Loading…
Cancel
Save