Skip to content

Commit

Permalink
refactor(aria.js): revise "propList to HTML"
Browse files Browse the repository at this point in the history
Revises "proplist to HTML" aka generating the index of states and
properties.
* replaces loop of string concatenation with map and join
* switch to template strings
* switch to insertAdjanceHTML & remove

test.sh run is clean.
  • Loading branch information
pkra committed Nov 28, 2023
1 parent 4ae0030 commit ae43f63
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions script/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,20 @@ function ariaAttributeReferences() {
});

if (!skipIndex) {
// we have all the properties and states - spit out the
// index
let propIndex = "";

for (let item of Object.values(propList)) {
propIndex +=
'<dt><a href="#' +
item.title +
'" class="' +
item.is +
'-reference">' +
item.name +
"</a></dt>\n";
propIndex += "<dd>" + item.desc + "</dd>\n";
}
let node = document.getElementById("index_state_prop");
parentNode = node.parentNode;
let l = document.createElement("dl");
l.id = "index_state_prop";
l.className = "compact";
l.innerHTML = propIndex;
parentNode.replaceChild(l, node);
// Generate index of states and properties
const indexStatePropPlaceholder =
document.getElementById("index_state_prop");
const indexStatePropContent = Object.values(propList)
.map(
(item) =>
`<dt><a href="#${item.title}" class="${item.is}-reference">${item.name}</a></dt>\n<dd>${item.desc}</dd>\n`
)
.join("");
indexStatePropPlaceholder.insertAdjacentHTML(
"afterend",
`<dl id="index_state_prop" class="compact">${indexStatePropContent}</dl>`
);
indexStatePropPlaceholder.remove();

let globalSPIndex = "";
for (let lItem of globalSP) {
Expand Down

0 comments on commit ae43f63

Please sign in to comment.