Fix HTML Console Error in Reports (#912)
Some checks are pending
Run Link Checker for Cron Job / markdown-link-check (push) Waiting to run

This commit is contained in:
ObedAmpahECS
2026-02-06 08:43:01 -08:00
committed by GitHub
parent 84aee722e5
commit 0201de41df

View File

@@ -263,23 +263,19 @@ const applyScopeAttributes = () => {
let tbody = table.querySelector("tbody")
if (!tbody) throw new Error(
`Invalid HTML structure, <table id='${tables[table].getAttribute("id")}'> does not have a <tbody> tag.`
`Invalid HTML structure, <table id='${tables[table]?.getAttribute("id")}'> does not have a <tbody> tag.`
)
let cols, rows;
if (tbody.children && tbody.children.length > 1) {
if (table.querySelectorAll("thead > tr > th")) {
cols = table.querySelectorAll("thead > tr > th")
}
else if (tbody.children[0].querySelectorAll("th")) {
cols = tbody.children[0].querySelectorAll("th")
}
for (let col of cols) {
col.setAttribute("scope", "col")
if (tbody.children && tbody.children.length > 0) {
for (let child of tbody.children) {
if (child.querySelectorAll("tr > th")) {
cols = table.querySelectorAll("tr > th")
for (let col of cols) {
col.setAttribute("scope", "col")
}
}
}
let trIdx = (table.classList.contains("caps_table")) ? 1 : 0
@@ -291,14 +287,12 @@ const applyScopeAttributes = () => {
row.children[trIdx].setAttribute("scope", "row")
}
}
}
else throw new Error(
`Unable to apply scope attributes to columns/rows,
<tbody> of <table id='${tables[table].getAttribute("id")}'> does not contain children or has no rows.`
<tbody> of <table id='${tables[table]?.getAttribute("id")}'> does not contain children or has no rows.`
)
}
} catch (error) {