diff --git a/public/table-sort.js b/public/table-sort.js index be7e136..4eaf139 100644 --- a/public/table-sort.js +++ b/public/table-sort.js @@ -54,6 +54,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) { return sortableTable.querySelector("tbody"); } } else { + // if or exists below the browser will make return sortableTable.querySelector("tbody"); } } @@ -110,6 +111,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"); diff --git a/test/missingTableTags.test.js b/test/missingTableTags.test.js index 3156316..7433c8e 100644 --- a/test/missingTableTags.test.js +++ b/test/missingTableTags.test.js @@ -13,7 +13,7 @@ test("test no missing table tags - (user has put and )", () => { ).toStrictEqual(["Alpha", "Bravo", "Charlie", "Delta", "Echo"]); }); -test("test with missing tag - (tbody and thead exist)", () => { +test("test with missing tag - thead exist", () => { expect( createTestTableMissingBodyTag([ "Echo", @@ -37,7 +37,7 @@ test("test with missing tag)", () => { ).toStrictEqual(["Alpha", "Bravo", "Charlie", "Delta", "Echo"]); }); -test("test with missing and tags - (tbody and thead exist)", () => { +test("test with missing and tags", () => { expect( createTestTableMissingBodyAndHeadTag([ "Echo",