Skip to content

Commit eb5646d

Browse files
authored
Merge branch 'master' into update-aria-query
2 parents d72d360 + 642aef8 commit eb5646d

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

__tests__/src/rules/heading-has-content-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ ruleTester.run('heading-has-content', rule, {
3838
{ code: '<h1>{foo.bar}</h1>' },
3939
{ code: '<h1 dangerouslySetInnerHTML={{ __html: "foo" }} />' },
4040
{ code: '<h1 children={children} />' },
41+
{ code: '<h1 aria-hidden />' },
4142
].map(parserOptionsMapper),
4243
invalid: [
4344
{ code: '<h1 />', errors: [expectedError] },

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"aria-query": "^2.0.0",
6464
"array-includes": "^3.0.3",
6565
"ast-types-flow": "^0.0.7",
66-
"axobject-query": "^1.0.2",
66+
"axobject-query": "^2.0.1",
6767
"damerau-levenshtein": "^1.0.4",
6868
"emoji-regex": "^6.5.1",
6969
"has": "^1.0.1",

src/rules/heading-has-content.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import { elementType } from 'jsx-ast-utils';
1111
import { generateObjSchema, arraySchema } from '../util/schemas';
1212
import hasAccessibleChild from '../util/hasAccessibleChild';
13+
import isHiddenFromScreenReader from '../util/isHiddenFromScreenReader';
1314

1415
const errorMessage =
1516
'Headings must have content and the content must be accessible by a screen reader.';
@@ -43,6 +44,8 @@ module.exports = {
4344
return;
4445
} else if (hasAccessibleChild(node.parent)) {
4546
return;
47+
} else if (isHiddenFromScreenReader(nodeType, node.attributes)) {
48+
return;
4649
}
4750

4851
context.report({

0 commit comments

Comments
 (0)