From 63374355ca8823729f79551983a6c7f4eeb4dd72 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Tue, 27 Oct 2015 20:43:48 -0500 Subject: [PATCH] Core: Fix parser detect of columns that don't exist due to colspan And prevent error if config.sortVars is undefined See #746 & #1047 --- js/jquery.tablesorter.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index dcdbdc8d..632f1a66 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -577,6 +577,10 @@ // cache headers per column c.$headerIndexed = []; for ( indx = 0; indx < c.columns; indx++ ) { + // colspan in header making a column undefined + if ( ts.isEmptyObject( c.sortVars[ indx ] ) ) { + c.sortVars[ indx ] = {}; + } $temp = c.$headers.filter( '[data-column="' + indx + '"]' ); // target sortable column cells, unless there are none, then use non-sortable cells // .last() added in jQuery 1.4; use .filter(':last') to maintain compatibility with jQuery v1.2.6 @@ -661,7 +665,7 @@ extractor = false; } if ( !parser ) { - parser = ts.detectParserForColumn( c, rows, -1, indx ); + parser = ts.detectParserForColumn( c, rows, -1, colIndex ); } if ( c.debug ) { debug[ '(' + colIndex + ') ' + header.text() ] = { @@ -890,13 +894,11 @@ max = c.columns; for ( colIndex = 0; colIndex < max; ++colIndex ) { cell = $row[ 0 ].cells[ colIndex ]; - if ( cell ) { - if ( typeof parsers[ cacheIndex ] === 'undefined' ) { - if ( c.debug ) { - console.warn( 'No parser found for cell:', cell, 'does it have a header?' ); - } - continue; + if ( typeof parsers[ cacheIndex ] === 'undefined' ) { + if ( c.debug ) { + console.warn( 'No parser found for column ' + colIndex + '; cell:', cell, 'does it have a header?' ); } + } else if ( cell ) { val = ts.getElementText( c, cell, cacheIndex ); rowData.raw[ cacheIndex ] = val; // save original row text txt = ts.getParsedText( c, cell, cacheIndex, val );