fixed missing class name error

This commit is contained in:
Rob Garrison 2011-08-23 09:07:28 -05:00
parent 42529b5d4b
commit 72f621306b
5 changed files with 23 additions and 12 deletions

View File

@ -28,6 +28,10 @@ Included all original [document pages](http://mottie.github.com/tablesorter/docs
View the [complete listing here](http://mottie.github.com/tablesorter/changelog.txt). View the [complete listing here](http://mottie.github.com/tablesorter/changelog.txt).
#### Version 2.0.15 (2011-08-23)
* Fixed a problem that caused a javascript error when a table header cell doesn't have a class name.
#### Version 2.0.14 (2011-08-22) #### Version 2.0.14 (2011-08-22)
* Reverted the changes made in 2.0.13 and added checks to prevent errors. * Reverted the changes made in 2.0.13 and added checks to prevent errors.

View File

@ -1,5 +1,10 @@
TableSorter Change Log TableSorter Change Log
Version 2.0.15 (2011-08-23)
============================
* Fixed a problem that caused a javascript error when a table header cell doesn't have a class name.
Version 2.0.14 (2011-08-22) Version 2.0.14 (2011-08-22)
============================ ============================

View File

@ -36,7 +36,7 @@
</div> </div>
<p> <p>
<strong>Author:</strong> <a class="external" href="http://lovepeacenukes.com">Christian Bach</a><br> <strong>Author:</strong> <a class="external" href="http://lovepeacenukes.com">Christian Bach</a><br>
<strong>Version:</strong> 2.0.14 (<a href="../changelog.txt">changelog</a>)<br> <strong>Version:</strong> 2.0.15 (<a href="../changelog.txt">changelog</a>)<br>
<strong>Licence:</strong> <strong>Licence:</strong>
Dual licensed under <a class="external" href="http://www.opensource.org/licenses/mit-license.php">MIT</a> Dual licensed under <a class="external" href="http://www.opensource.org/licenses/mit-license.php">MIT</a>
or <a class="external" href="http://www.opensource.org/licenses/gpl-license.php">GPL</a> licenses. or <a class="external" href="http://www.opensource.org/licenses/gpl-license.php">GPL</a> licenses.

View File

@ -1,6 +1,6 @@
/* /*
* TableSorter 2.0 - Client-side table sorting with ease! * TableSorter 2.0 - Client-side table sorting with ease!
* Version 2.0.14 * Version 2.0.15
* @requires jQuery v1.2.3 * @requires jQuery v1.2.3
* *
* Copyright (c) 2007 Christian Bach * Copyright (c) 2007 Christian Bach
@ -194,20 +194,21 @@
function buildParserCache(table, $headers) { function buildParserCache(table, $headers) {
if (table.tBodies.length === 0) { return; } // In the case of empty tables if (table.tBodies.length === 0) { return; } // In the case of empty tables
var rows = table.tBodies[0].rows, list, cells, l, i, p, parsersDebug = ""; var rows = table.tBodies[0].rows, list, cells, l, h, i, p, parsersDebug = "";
if (rows[0]) { if (rows[0]) {
list = []; list = [];
cells = rows[0].cells; cells = rows[0].cells;
l = cells.length; l = cells.length;
for (i = 0; i < l; i++) { for (i = 0; i < l; i++) {
p = false; p = false;
if ($.metadata && ($($headers[i]).metadata() && $($headers[i]).metadata().sorter)) { h = $($headers[i]);
p = getParserById($($headers[i]).metadata().sorter); if ($.metadata && (h.metadata() && h.metadata().sorter)) {
p = getParserById(h.metadata().sorter);
} else if ((table.config.headers[i] && table.config.headers[i].sorter)) { } else if ((table.config.headers[i] && table.config.headers[i].sorter)) {
p = getParserById(table.config.headers[i].sorter); p = getParserById(table.config.headers[i].sorter);
} else if ($($headers[i]).attr('class').match('sorter-')){ } else if (h.attr('class') && h.attr('class').match('sorter-')){
// include sorter class name "sorter-text", etc // include sorter class name "sorter-text", etc
p = getParserById($($headers[i]).attr('class').match(/sorter-(\w+)/)[1] || ''); p = getParserById(h.attr('class').match(/sorter-(\w+)/)[1] || '');
} }
if (!p) { if (!p) {
p = detectParserForColumn(table, rows, -1, i); p = detectParserForColumn(table, rows, -1, i);
@ -226,8 +227,9 @@
/* utils */ /* utils */
function buildCache(table) { function buildCache(table) {
var totalRows = (table.tBodies[0] && table.tBodies[0].rows.length) || 0, var b = table.tBodies[0],
totalCells = (table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells.length) || 0, totalRows = (b && b.rows.length) || 0,
totalCells = (b.rows[0] && b.rows[0].cells.length) || 0,
parsers = table.config.parsers, parsers = table.config.parsers,
cache = { cache = {
row: [], row: [],
@ -239,7 +241,7 @@
} }
for (i = 0; i < totalRows; ++i) { for (i = 0; i < totalRows; ++i) {
/** Add the table data to main data array */ /** Add the table data to main data array */
c = $(table.tBodies[0].rows[i]); c = $(b.rows[i]);
cols = []; cols = [];
// if this is a child row, add it to the last row's children and // if this is a child row, add it to the last row's children and
// continue to the next row // continue to the next row

File diff suppressed because one or more lines are too long