Skip to content

Commit

Permalink
Core: Show console error for mismatched column count. See #1415
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Jun 8, 2017
1 parent 8dbd34e commit 23c94a7
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions js/jquery.tablesorter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2275,9 +2275,42 @@
}
}
}
ts.checkColumnCount($rows, matrix, matrixrow.length);
return matrixrow.length;
},

checkColumnCount : function($rows, matrix, columns) {
// this DOES NOT report any tbody column issues, except for the math and
// and column selector widgets
var i, len,
valid = true,
cells = [];
for ( i = 0; i < matrix.length; i++ ) {
// some matrix entries are undefined when testing the footer because
// it is using the rowIndex property
if ( matrix[i] ) {
len = matrix[i].length;
if ( matrix[i].length !== columns ) {
valid = false;
break;
}
}
}
if ( !valid ) {
$rows.each( function( indx, el ) {
var cell = el.parentElement.nodeName;
if ( cells.indexOf( cell ) ) {
cells.push( cell );
}
});
console.error(
'Invalid or incorrect number of columns in the ' +
cells.join( ' or ' ) + '; expected ' + columns +
', but found ' + len + ' columns'
);
}
},

// automatically add a colgroup with col elements set to a percentage width
fixColumnWidth : function( table ) {
table = $( table )[ 0 ];
Expand Down

0 comments on commit 23c94a7

Please sign in to comment.