diff --git a/src/__tests__/__snapshots__/role-helpers.js.snap b/src/__tests__/__snapshots__/role-helpers.js.snap
index e31f7a64..ef5746b2 100644
--- a/src/__tests__/__snapshots__/role-helpers.js.snap
+++ b/src/__tests__/__snapshots__/role-helpers.js.snap
@@ -7,6 +7,14 @@ exports[`logRoles calls console.log with output from prettyRoles 1`] = `
data-testid="a-section"
/>
+--------------------------------------------------
+link:
+
+
+
--------------------------------------------------
navigation:
diff --git a/src/__tests__/role-helpers.js b/src/__tests__/role-helpers.js
index ea956ad0..60b05c67 100644
--- a/src/__tests__/role-helpers.js
+++ b/src/__tests__/role-helpers.js
@@ -6,6 +6,9 @@ afterEach(cleanup)
function setup() {
const {getByTestId} = render(`
+ link
+ invalid link
+
Main Heading
@@ -54,6 +57,7 @@ function setup() {
return {
section: getByTestId('a-section'),
+ anchor: getByTestId('a-link'),
h1: getByTestId('a-h1'),
h2: getByTestId('a-h2'),
h3: getByTestId('a-h3'),
@@ -85,6 +89,7 @@ function setup() {
test('getRoles returns expected roles for various dom nodes', () => {
const {
section,
+ anchor,
h1,
h2,
h3,
@@ -113,6 +118,7 @@ test('getRoles returns expected roles for various dom nodes', () => {
} = setup()
expect(getRoles(section)).toEqual({
+ link: [anchor],
region: [section],
heading: [h1, h2, h3],
navigation: [nav],
diff --git a/src/role-helpers.js b/src/role-helpers.js
index 0c21cb8a..a4fdefed 100644
--- a/src/role-helpers.js
+++ b/src/role-helpers.js
@@ -16,7 +16,9 @@ function getImplicitAriaRoles(currentNode) {
function buildElementRoleList(elementRolesMap) {
function makeElementSelector({name, attributes = []}) {
return `${name}${attributes
- .map(({name: attributeName, value}) => `[${attributeName}=${value}]`)
+ .map(({name: attributeName, value}) =>
+ value ? `[${attributeName}=${value}]` : `[${attributeName}]`,
+ )
.join('')}`
}