Skip to content

Commit

Permalink
refactor(aria.js): improve propList loop
Browse files Browse the repository at this point in the history
Starts from the end and tightens up  HTML generation for the
last variation of placeholder.

test.sh run is clean.
  • Loading branch information
pkra committed Dec 12, 2023
1 parent ec02902 commit 91028b3
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions script/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,21 +611,14 @@ function ariaAttributeReferences() {
item.roles.length
) {
// for prohibited roles the roles list just includes those roles which are prohibited... weird I know but it is what it is
let sortedList = [];
sortedList = item.roles.sort();
//remove roletype from the sorted list
const index = sortedList.indexOf("roletype");
if (index > -1) {
sortedList.splice(index, 1);
}
output +=
"All elements of the base markup except for the following roles: ";
for (let j = 0; j < sortedList.length - 1; j++) {
output += "<rref>" + sortedList[j] + "</rref>, ";
}
output +=
"<rref>" + sortedList[sortedList.length - 1] + "</rref>";
placeholder.innerHTML = output;
// exclude roletype from the sorted list
const sortedList = item.roles
.sort()
.filter((role) => role !== "roletype");

placeholder.innerHTML = `All elements of the base markup except for the following roles: ${sortedList
.map((role) => `<rref>${role}</rref>`)
.join(", ")}`;
}
});

Expand Down

0 comments on commit 91028b3

Please sign in to comment.