jquery.tablesorter: Remove dead node check in getElementSortKey()
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 8 Mar 2019 15:30:27 +0000 (15:30 +0000)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 8 Mar 2019 20:38:47 +0000 (20:38 +0000)
In 2012, commit 39d1f3967be9d added special handling image elements,
and for Cite references. This inadvertently broke handling of sorting
for tables with colspanned cells, which have node = undefined in the
cache.

In 2013, commit e203fdfc74f18 restored handling of node = undefined.

In 2015, commit 7a5f4e46d10ea made colspan expanded in the cache
just as rowspan was already. Thus making this code dead.

It's odd to see $(node) before this check, and even a call within
this conditional. This worked, as long way to return ''.

Change-Id: Ia823a3ec29371be39fab3d626ed8647ee469951b

resources/src/jquery.tablesorter/jquery.tablesorter.js

index 6107af1..a5a1783 100644 (file)
                return false;
        }
 
+       /**
+        * @param {HTMLElement} node
+        * @return {string}
+        */
        function getElementSortKey( node ) {
                var $node = $( node ),
                        // Use data-sort-value attribute.
@@ -71,9 +75,6 @@
                        // like charAt, toLowerCase and split are expected.
                        return String( data );
                }
-               if ( !node ) {
-                       return $node.text();
-               }
                if ( node.tagName.toLowerCase() === 'img' ) {
                        return $node.attr( 'alt' ) || ''; // handle undefined alt
                }