From b8ffb39785188dd230431f4f53825f1fe42ee3af Mon Sep 17 00:00:00 2001 From: Steven Lambert <2433219+straker@users.noreply.github.com> Date: Thu, 18 Jun 2020 10:57:13 -0600 Subject: [PATCH] fix(header-present): fail for headings with non-header role (#2306) --- lib/checks/navigation/header-present.json | 2 +- test/checks/navigation/header-present.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/checks/navigation/header-present.json b/lib/checks/navigation/header-present.json index 056d6c2757..a1a256a797 100644 --- a/lib/checks/navigation/header-present.json +++ b/lib/checks/navigation/header-present.json @@ -2,7 +2,7 @@ "id": "header-present", "evaluate": "has-descendant-evaluate", "options": { - "selector": "h1, h2, h3, h4, h5, h6, [role=heading]" + "selector": "h1:not([role]), h2:not([role]), h3:not([role]), h4:not([role]), h5:not([role]), h6:not([role]), [role=heading]" }, "metadata": { "impact": "serious", diff --git a/test/checks/navigation/header-present.js b/test/checks/navigation/header-present.js index 8e534efa21..8cd8f36f2d 100644 --- a/test/checks/navigation/header-present.js +++ b/test/checks/navigation/header-present.js @@ -75,6 +75,17 @@ describe('header-present', function() { ); }); + it('should return false if heading has a different role', function() { + var params = checkSetup( + '

Some stuff and stuff

' + ); + assert.isFalse( + axe.testUtils + .getCheckEvaluate('header-present') + .apply(checkContext, params) + ); + }); + (shadowSupported ? it : xit)( 'should return true if heading is in shadow dom', function() {