Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/checks/shared/presentational-role-evaluate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getExplicitRole, getRole } from '../../commons/aria';
import { getExplicitRole, getRole, hasAriaValue } from '../../commons/aria';
import { getGlobalAriaAttrs } from '../../commons/standards';
import { isFocusable } from '../../commons/dom';

Expand Down Expand Up @@ -34,8 +34,10 @@ export default function presentationalRoleEvaluate(node, options, virtualNode) {

// user intended to make this presentational so inform them of
// problems caused by role conflict resolution
// use hasAriaValue so a global ARIA attribute supplied via the reflected AOM
// property or element internals counts, not only the HTML attribute
const hasGlobalAria = getGlobalAriaAttrs().some(attr =>
virtualNode.hasAttr(attr)
hasAriaValue(virtualNode, attr)
Comment thread
chutchins25 marked this conversation as resolved.
Outdated
);
const focusable = isFocusable(virtualNode);
let messageKey;
Expand Down
21 changes: 21 additions & 0 deletions test/checks/shared/presentational-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ describe('presentational-role', () => {
assert.deepEqual(checkContext._data.messageKey, 'both');
});

it('detects a global aria attribute set via the reflected AOM property', () => {
const vNode = queryFixture(
'<button id="target" role="none">Still a button</button>'
);
// set via the property (no aria-live attribute present)
vNode.actualNode.ariaLive = 'assertive';

assert.isFalse(checkEvaluate.call(checkContext, null, null, vNode));
assert.deepEqual(checkContext._data.messageKey, 'both');
});

it('detects a global aria attribute set via element internals', () => {
const vNode = queryFixture(
'<testutils-element id="target" no-role role="none" tabindex="0">x</testutils-element>'
);
vNode.actualNode._internals.ariaLive = 'assertive';
Comment thread
chutchins25 marked this conversation as resolved.
Outdated

assert.isFalse(checkEvaluate.call(checkContext, null, null, vNode));
Comment thread
chutchins25 marked this conversation as resolved.
Outdated
assert.deepEqual(checkContext._data.messageKey, 'both');
});

it('should return false for iframe element with role=none and title', () => {
const vNode = queryFixture(
'<iframe id="target" role="none" title=" "></iframe>'
Expand Down
Loading