FyiurAmron/sortablejs

colspans in table result in undefined `node` in `getInnerText`, breaking the sort (JS error)

FyiurAmron opened this issue · 1 comments

It happens since colspans result in essentially no node at the required location.

Easily fixable by replacing

  getInnerText: function(node) {
    //
    hasInputs = (typeof node.getElementsByTagName == 'function') &&
                 node.getElementsByTagName('input').length;

with

  getInnerText: function(node) {
    //
    if ( !node ) {
      return "";
    }

    hasInputs = (typeof node.getElementsByTagName == 'function') &&
                 node.getElementsByTagName('input').length;

It does result in colspans being treated as empty cells, which IMO should be the expected behaviour. They get sorted properly afterwards, usually going on the top or the bottom of the sorted table.

fixed in #26