Skip to content

Commit

Permalink
Fix failing tests by checking tableRows.innertext() not false before …
Browse files Browse the repository at this point in the history
…making match.
  • Loading branch information
LeeWannacott committed May 14, 2023
1 parent ca8fa26 commit 95fe446
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions public/table-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
};
let classNameAdded = false;
let regexNotFoundCount = 0;
const threshold = Math.ceil(tableRows.length/ 2);
const threshold = Math.ceil(tableRows.length / 2);
for (let tr of tableRows) {
if (regexNotFoundCount >= threshold) {
break;
Expand All @@ -82,9 +82,11 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
let foundMatch = false;
for (let key of Object.keys(inferableClasses)) {
let classRegexp = inferableClasses[key].regexp;
if (tableColumn.innerText.match(classRegexp) !== null) {
foundMatch = true;
inferableClasses[key].count++;
if (tableColumn.innerText) {
if (tableColumn.innerText.match(classRegexp) !== null) {
foundMatch = true;
inferableClasses[key].count++;
}
}
if (inferableClasses[key].count >= threshold) {
th.classList.add(inferableClasses[key].class);
Expand Down

0 comments on commit 95fe446

Please sign in to comment.