fix: relax no-redundant-roles implementation (#8536)

Deals with the no-redundant-roles part of #8529

There was an erroneous check which compares the element name with the current role. This fix brings no-redundant-roles closer to the original eslint-jsx implementation
pull/8540/head
Nguyen Tran 1 year ago committed by GitHub
parent 6ba2f72251
commit f064c39d5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -121,6 +121,7 @@ const a11y_implicit_semantics = new Map([
['details', 'group'],
['dt', 'term'],
['fieldset', 'group'],
['figure', 'figure'],
['form', 'form'],
['h1', 'heading'],
['h2', 'heading'],
@ -132,6 +133,7 @@ const a11y_implicit_semantics = new Map([
['img', 'img'],
['li', 'listitem'],
['link', 'link'],
['main', 'main'],
['menu', 'list'],
['meter', 'progressbar'],
['nav', 'navigation'],
@ -142,6 +144,7 @@ const a11y_implicit_semantics = new Map([
['progress', 'progressbar'],
['section', 'region'],
['summary', 'button'],
['table', 'table'],
['tbody', 'rowgroup'],
['textarea', 'textbox'],
['tfoot', 'rowgroup'],
@ -631,9 +634,7 @@ export default class Element extends Node {
}
// no-redundant-roles
const has_redundant_role = current_role === get_implicit_role(this.name, attribute_map);
if (this.name === current_role || has_redundant_role) {
if (current_role === get_implicit_role(this.name, attribute_map)) {
component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(current_role));
}

@ -41,4 +41,8 @@
<!-- Tested header/footer not nested in section/article -->
<header role="banner"></header>
<footer role="contentinfo"></footer>
<footer role="contentinfo"></footer>
<!-- Allowed -->
<!-- svelte-ignore a11y-no-noninteractive-element-to-interactive-role -->
<menu role="menu" />

Loading…
Cancel
Save