Skip to content

Commit

Permalink
Use aria-describedby on <summary> (#1134)
Browse files Browse the repository at this point in the history
It can be unclear for a non-visual user which row the details element is for.
  • Loading branch information
zcorpan authored Dec 11, 2024
1 parent 94e53db commit 373de6a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,14 @@ <h2>Legend</h2>
return [dt, dd];
}

function details(description, rationale) {
function details(description, rationale, describedById) {
if (!description && !rationale) {
return null;
}
const details = document.createElement('details');
const summary = document.createElement('summary');
summary.textContent = 'Details';
summary.setAttribute('aria-describedby', describedById);
details.append(summary);
const dl = document.createElement('dl');
details.append(dl);
Expand Down Expand Up @@ -357,7 +358,9 @@ <h2>Legend</h2>
tr.append(cell(link(`#${selfId}`, '🔗', 'Self-link'), 'link'));

// Specification
tr.append(cell(link(url, title), 'specification'));
const specLink = link(url, title);
specLink.id = `speclink-${selfId}`;
tr.append(cell(specLink, 'specification'));

// Position
tr.append(cell(positionSpan(position), 'positions'));
Expand Down Expand Up @@ -393,7 +396,7 @@ <h2>Legend</h2>
if (description || rationale) {
const detailsTr = document.createElement('tr');
detailsTr.className = 'details';
detailsTr.append(cell(details(description, rationale), null, 7));
detailsTr.append(cell(details(description, rationale, specLink.id), null, 7));
rv.push(detailsTr);
}

Expand Down

0 comments on commit 373de6a

Please sign in to comment.