Skip to content

Commit ffa45d0

Browse files
committed
docs(template-no-unsupported-role-attributes): document specificity heuristic
The "pick entry with most attribute constraints satisfied" resolution is a heuristic, not a spec-documented approach. aria-query's elementRoles is an unordered Map; aria-query does not publish a resolution order for multi-match cases. Name the inference, cite the motivating bug cases, and note that if aria-query ever publishes resolution semantics we should switch to those.
1 parent 088ab85 commit ffa45d0

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

lib/rules/template-no-unsupported-role-attributes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ function getImplicitRole(node) {
5252
// Each elementRoles entry lists attributes that must match (with optional
5353
// constraints "set" / "undefined"); pick the most specific entry whose
5454
// attribute spec is fully satisfied by the node.
55+
//
56+
// Heuristic: "specificity = attribute-constraint count". aria-query exports
57+
// elementRoles as an unordered Map and does not document how consumers
58+
// should resolve multi-match cases; this count-based tiebreak is an
59+
// inference from the data shape. It resolves the motivating bugs:
60+
// - <input type="text"> without `list` → textbox, not combobox
61+
// (the combobox entry requires `list=set`, a stricter 2-attr match;
62+
// the textbox entry's 1-attr type=text wins when `list` is absent).
63+
// - <input type="password"> → no role (no elementRoles entry matches).
64+
// If aria-query ever publishes a resolution order, switch to that.
5565
let bestKey;
5666
let bestSpecificity = -1;
5767
for (const key of elementRoles.keys()) {

0 commit comments

Comments
 (0)