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

TypeError: tableBody is null #93

Closed
strager opened this issue May 19, 2023 · 2 comments
Closed

TypeError: tableBody is null #93

strager opened this issue May 19, 2023 · 2 comments
Assignees

Comments

@strager
Copy link
Contributor

strager commented May 19, 2023

If I create a table without a <tbody>, the table-sort-js browser extension crashes with TypeError: tableBody is null.

<section id="log-section">
  <table id="log-table">
    <thead>
      <tr>
        <th>file offset</th>
        <th>stream</th>
        <th>stream offset</th>
        <th>message</th>
      </tr>
    </thead>
  </table>
</section>
@kyle-wannacott
Copy link
Owner

Sounds fixable it's because the browser extension applies table-sort tag to all tables. I could create a tbody if it doesn't exist (Like I do with <thead>) ,or just exit out, or do a check for null before trying to grab tbody.

function makeTableSortable(sortableTable) {
const tableBody = getTableBody(sortableTable);
const tableHead = sortableTable.querySelector("thead");
const tableHeadHeaders = tableHead.querySelectorAll("th");
const tableRows = tableBody.querySelectorAll("tr");

It's this line here.

@kyle-wannacott kyle-wannacott self-assigned this May 21, 2023
@kyle-wannacott
Copy link
Owner

Should be fixed in: #99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants