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

Whitespace breaks date sorting in Firefox #188

Open markhobson opened 4 years ago

markhobson commented 4 years ago

Whitespace around dates breaks sorting in Firefox, but is fine under Chrome:

https://jsfiddle.net/markhobson/4qmhgzwe/6/

A cursory glance indicates that new Date(date) in tablesort.date.js is not cross-browser compatible:

Firefox:

> new Date(' 2000-01-02 ');
< Invalid Date

Chrome:

> new Date(' 2000-01-02 ');
< Sun Jan 02 2000 00:00:00 GMT+0000 (Greenwich Mean Time) {}
moseslecce commented 4 years ago

I would think the responsibility of the data to be appropriately formatted is outside of the scope of the sorting library. Should the library really sanitize all of the inputs?

tristen commented 4 years ago

Should the library really sanitize all of the inputs

Agree. Pull request happily accepted.