Skip to content

Commit

Permalink
refactor(aria.js): child roles generation
Browse files Browse the repository at this point in the history
Refactor into forEach + map + template strings.

test.sh run is clean.
  • Loading branch information
pkra committed Dec 13, 2023
1 parent 4d5b37b commit 22aac2a
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions script/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,24 +585,14 @@ function ariaAttributeReferences() {
).outerHTML = `<ul id="index_fromheading" class="compact">${fromHeading}</ul>`;

// assuming we found some parent roles, update those parents with their children
for (let i = 0; i < subRoles.length; i++) {
const item = subRoles[subRoles[i]];
const sortedList = item;
let output = "<ul>\n";
for (let j = 0; j < sortedList.length; j++) {
output += "<li><rref>" + sortedList[j] + "</rref></li>\n";
}
output += "</ul>\n";
// put it somewhere
const subRolesContainer = document.querySelector("#" + subRoles[i]);
if (subRolesContainer) {
const subRolesListContainer =
subRolesContainer.querySelector(".role-children");
if (subRolesListContainer) {
subRolesListContainer.innerHTML = output;
}
}
}
subRoles.forEach((role) => {
const item = subRoles[role]; //TODO: cf. populateSubRoles overloading
document.querySelector(
`#${role} .role-children`
).innerHTML = `<ul>\n${item
.map((subrole) => `<li><rref>${subrole}</rref></li>\n`)
.join("")}</ul>\n`;
});
}

// prune out unused rows throughout the document
Expand Down

0 comments on commit 22aac2a

Please sign in to comment.