Skip to content

Commit b82b1bd

Browse files
authored
Merge pull request #705 from jsx-eslint/fix-heading-error
Fix aria-level error for the heading role (#704)
2 parents 3ac1738 + 765da0f commit b82b1bd

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

__tests__/src/rules/role-supports-aria-props-test.js

+2
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ ruleTester.run('role-supports-aria-props', rule, {
381381
{ code: '<textarea aria-hidden />' },
382382
{ code: '<select aria-expanded />' },
383383
{ code: '<datalist aria-expanded />' },
384+
{ code: '<div role="heading" aria-level />' },
385+
{ code: '<div role="heading" aria-level="1" />' },
384386

385387
].concat(validTests).map(parserOptionsMapper),
386388

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"license": "MIT",
6060
"dependencies": {
6161
"@babel/runtime": "^7.10.2",
62-
"aria-query": "^4.2.0",
62+
"aria-query": "^4.2.2",
6363
"array-includes": "^3.1.1",
6464
"ast-types-flow": "^0.0.7",
6565
"axe-core": "^3.5.4",

src/util/isNonInteractiveElement.js

+7
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ const isNonInteractiveElement = (
149149
if (!dom.has(tagName)) {
150150
return false;
151151
}
152+
// <header> elements do not technically have semantics, unless the
153+
// element is a direct descendant of <body>, and this plugin cannot
154+
// reliably test that.
155+
// @see https://www.w3.org/TR/wai-aria-practices/examples/landmarks/banner.html
156+
if (tagName === 'header') {
157+
return false;
158+
}
152159

153160
return checkIsNonInteractiveElement(tagName, attributes);
154161
};

0 commit comments

Comments
 (0)