Skip to content

Commit a4699da

Browse files
committed
test(commons/aria): document presentation inheritance for internal roles
Custom elements exposing a required-child role via ElementInternals do not inherit a presentational role from an ancestor role=none list, since inheritance is keyed off the HTML tag name. See #5181.
1 parent e6c54f3 commit a4699da

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/commons/aria/get-role.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,27 @@ describe('aria.getRole', () => {
245245
aria.getRole(node);
246246
});
247247
});
248+
249+
// Presentational role inheritance is keyed off the HTML tag name of the
250+
// required child (e.g. `li`, `td`), not its computed role. A custom element
251+
// exposing an internal `listitem` role is not an HTML `<li>`, so it does not
252+
// inherit a presentational role from an ancestor `role="none"` list. Whether
253+
// it should is an open spec/browser question — see issue #5181.
254+
it('does not inherit presentation onto an ElementInternals listitem role', () => {
255+
fixture.innerHTML =
256+
'<ul role="none"><testutils-element with-role="listitem" id="target"></testutils-element></ul>';
257+
flatTreeSetup(fixture);
258+
const node = fixture.querySelector('#target');
259+
assert.equal(aria.getRole(node), 'listitem');
260+
});
261+
262+
it('does not inherit presentation onto an ElementInternals non-child role', () => {
263+
fixture.innerHTML =
264+
'<ul role="none"><testutils-element with-role="button" id="target"></testutils-element></ul>';
265+
flatTreeSetup(fixture);
266+
const node = fixture.querySelector('#target');
267+
assert.equal(aria.getRole(node), 'button');
268+
});
248269
});
249270

250271
describe('noImplicit', () => {

0 commit comments

Comments
 (0)