Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for table.body being null. Issue #93 #99

Merged
merged 1 commit into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions public/table-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
return sortableTable.querySelector("tbody");
}
} else {
// if <tr> or <td> exists below <thead> the browser will make <tbody>
return sortableTable.querySelector("tbody");
}
}
Expand Down Expand Up @@ -111,6 +112,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
body: getTableBody(sortableTable),
head: sortableTable.querySelector("thead"),
};
if(table.body == null){ return }
table.headers = table.head.querySelectorAll("th");
table.rows = table.body.querySelectorAll("tr");

Expand Down
4 changes: 2 additions & 2 deletions test/missingTableTags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test("test no missing table tags - (user has put <tbody> and <thead>)", () => {
).toStrictEqual(["Alpha", "Bravo", "Charlie", "Delta", "Echo"]);
});

test("test with missing <tbody> tag - (tbody and thead exist)", () => {
test("test with missing <tbody> tag - thead exist", () => {
expect(
createTestTableMissingBodyTag([
"Echo",
Expand All @@ -37,7 +37,7 @@ test("test with missing <thead> tag)", () => {
).toStrictEqual(["Alpha", "Bravo", "Charlie", "Delta", "Echo"]);
});

test("test with missing <tbody> and <thead> tags - (tbody and thead exist)", () => {
test("test with missing <tbody> and <thead> tags", () => {
expect(
createTestTableMissingBodyAndHeadTag([
"Echo",
Expand Down