mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07:10 +00:00
fix(web): offer the aria roles a user activates
only role=button was in the tappable set, so link, checkbox, radio, switch, tab, option, the menuitems and treeitem were invisible to the enumeration however plain the control looked. the replay ui builds its step rows as <li role="option">, and the spec dogfooding it had to hand-write an action to reach them because no default verb could see a single row. both producers build the set from the same role list, since the parity test compares them element by element.
This commit is contained in:
1 parent
ce4f660098
commit
a460eba3db
3 files changed
+38
-2
No files matched your search
@@ -413,8 +413,13 @@ func (d *Driver) Hierarchy(ctx context.Context) (string, error) {
|
||||
visit(document);
|
||||
return out;
|
||||
}
|
||||
const TAPPABLE_ROLES = [
|
||||
'button', 'link', 'checkbox', 'radio', 'switch', 'tab', 'option',
|
||||
'menuitem', 'menuitemcheckbox', 'menuitemradio', 'treeitem'];
|
||||
const clickableSet = new Set(deepQuery(
|
||||
'a, button, input, select, textarea, [role="button"], [onclick]'));
|
||||
'a, button, input, select, textarea, ' +
|
||||
TAPPABLE_ROLES.map(role => '[role="' + role + '"]').join(', ') +
|
||||
', [onclick]'));
|
||||
const editableSet = new Set(deepQuery(
|
||||
'input, textarea, [contenteditable]').filter(isEditableElement));
|
||||
function buildTree(el, isRoot) {
|
||||
|
||||
@@ -56,6 +56,22 @@
|
||||
<textarea id="notes"></textarea>
|
||||
<div id="bio" contenteditable="true">bio</div>
|
||||
<div id="menu" role="button">menu</div>
|
||||
<!-- One element per ARIA role both producers resolve as clickable. A role
|
||||
covered on one side only makes that control reachable for one host,
|
||||
which is how the whole set is kept honest: role="option" is the shape
|
||||
the replay UI gives its step rows. -->
|
||||
<div id="role-link" role="link">link</div>
|
||||
<div id="role-checkbox" role="checkbox">checkbox</div>
|
||||
<div id="role-radio" role="radio">radio</div>
|
||||
<div id="role-switch" role="switch">switch</div>
|
||||
<div id="role-tab" role="tab">tab</div>
|
||||
<div id="role-menuitem" role="menuitem">menu item</div>
|
||||
<div id="role-menuitemcheckbox" role="menuitemcheckbox">menu item checkbox</div>
|
||||
<div id="role-menuitemradio" role="menuitemradio">menu item radio</div>
|
||||
<div id="role-treeitem" role="treeitem">tree item</div>
|
||||
<ul id="role-listbox" role="listbox">
|
||||
<li id="role-option" role="option">option</li>
|
||||
</ul>
|
||||
<div id="attribute-click" onclick="void 0">attribute click</div>
|
||||
<div id="delegating-root">delegating root</div>
|
||||
<div id="plain">plain</div>
|
||||
|
||||
@@ -569,7 +569,22 @@ function sanitizeAt(value: unknown, depth: number, seen: WeakSet<object>): unkno
|
||||
// only how the DOM answers "is this clickable" / "is this editable", the two
|
||||
// facts with no direct DOM equivalent of the accessibility attributes native
|
||||
// platforms expose.
|
||||
const TAPPABLE_SELECTOR = 'a, button, input, select, textarea, [role="button"], [onclick]';
|
||||
//
|
||||
// TAPPABLE_ROLES are the ARIA roles whose whole contract is that a user
|
||||
// activates the element. Covering only role="button" left every other one
|
||||
// invisible to the enumeration, however plain the control looked: the replay UI
|
||||
// builds its step rows as <li role="option">, and the spec dogfooding it had to
|
||||
// hand-write an action to reach them because no default verb could see a single
|
||||
// row. internal/driver/chrome/driver.go resolves the same set for the hierarchy
|
||||
// dump the goja host reads, and the two are compared element by element by
|
||||
// TestHierarchy_DerivesTheSameFactsAsTheWebRuntime.
|
||||
const TAPPABLE_ROLES = [
|
||||
"button", "link", "checkbox", "radio", "switch", "tab", "option",
|
||||
"menuitem", "menuitemcheckbox", "menuitemradio", "treeitem",
|
||||
];
|
||||
const TAPPABLE_SELECTOR = `a, button, input, select, textarea, ${
|
||||
TAPPABLE_ROLES.map((role) => `[role="${role}"]`).join(", ")
|
||||
}, [onclick]`;
|
||||
const EDITABLE_SELECTOR = "input, textarea, [contenteditable]";
|
||||
|
||||
const NON_TEXT_INPUT_TYPES = [
|
||||
|
||||
Reference in new issue
Block a user