mirror of
https://github.com/cisagov/ScubaGoggles.git
synced 2026-02-07 00:36:07 +01:00
Fix HTML Console Error in Reports (#912)
Some checks are pending
Run Link Checker for Cron Job / markdown-link-check (push) Waiting to run
Some checks are pending
Run Link Checker for Cron Job / markdown-link-check (push) Waiting to run
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user