tristen / tablesort

:arrow_up_down: A small tablesorter in plain JavaScript
https://tristen.ca/tablesort/demo/
MIT License
1.1k stars 179 forks source link

Remove check for falsy items variable in sortTable function #149

Closed andrewgonzales closed 4 years ago

andrewgonzales commented 6 years ago

The items variable is instantiated as an array in sortTable, so it will always be truthy, and !items on line 170 of tablesort.js will never evaluate. This update removes the extraneous check and clarifies the code.

andrewgonzales commented 6 years ago

I re-added the check, but with items.length instead of items. If a table has two or more header rows and no body rows, the early return for that.table.rows.length < 2 won't catch, so this check prevents unnecessary sortTable code from running, as intended, but is actually reachable.

My install works fine with my local machine node 6/npm 3, but fails when I set nvm to node v0.10 like in the Travis CI build.

tristen commented 4 years ago

Stale. Please re-open a new pull request if this is still an issue and include a test!