kylefox/jquery-tablesort — pull request #9 by elidupuis (2013-10-24 06:34:30+00:00)
Title: Make plugin compatible with Zepto

I tried to use this plugin with [Zepto](http://zeptojs.com/) instead of jQuery and it didn't work. These changes make it compatible.

First things first: Zepto doesn't have a `.data()` method by default—you need to make a [custom build](https://github.com/madrobby/zepto#building) with the data module. I've linked to a version of Zepto including the data module in [zepto.html](https://github.com/elidupuis/jquery-tablesort/blob/zepto/zepto.html#L120). The plugin will still fail if the `.data()` module is missing.

For some reason, Zepto and jQuery append the `tr`s differently during a sort—jQuery manages to put them into the `tbody` but Zepto moves them out and they become siblings to the `tbody` (see screenshot). Your `rows` [variable](https://github.com/elidupuis/jquery-tablesort/blob/master/jquery.tablesort.js#L30) now returns an empty array when a `thead` exists. This PR addresses that issue.

![screen shot 2013-10-24 at 12 19 11 am](https://f.cloud.github.com/assets/196410/1396813/54a0acbe-3c74-11e3-9b5f-00469714f5b8.png)

Finally, it turns out that browsers actually [insert a `tbody` element](http://stackoverflow.com/questions/938083/why-do-browsers-insert-tbody-element-into-table-elements#answer-938143) if one does not exist so theoretically there will always be a `tbody`. I haven't looked into cross browser behavior on this topic.