Permalink
Browse files

fixed missing class name error

  • Loading branch information...
1 parent 42529b5 commit 72f621306bdca0715c97ea5960172856f79df164 @Mottie committed Aug 23, 2011
Showing with 23 additions and 12 deletions.
  1. +4 −0 README.markdown
  2. +5 −0 changelog.txt
  3. +1 −1 docs/index.html
  4. +11 −9 js/jquery.tablesorter.js
  5. +2 −2 js/jquery.tablesorter.min.js
View
@@ -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).
+#### 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)
* Reverted the changes made in 2.0.13 and added checks to prevent errors.
View
@@ -1,5 +1,10 @@
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)
============================
View
@@ -36,7 +36,7 @@
</div>
<p>
<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>
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.
@@ -1,6 +1,6 @@
/*
* TableSorter 2.0 - Client-side table sorting with ease!
-* Version 2.0.14
+* Version 2.0.15
* @requires jQuery v1.2.3
*
* Copyright (c) 2007 Christian Bach
@@ -194,20 +194,21 @@
function buildParserCache(table, $headers) {
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]) {
list = [];
cells = rows[0].cells;
l = cells.length;
for (i = 0; i < l; i++) {
p = false;
- if ($.metadata && ($($headers[i]).metadata() && $($headers[i]).metadata().sorter)) {
- p = getParserById($($headers[i]).metadata().sorter);
+ h = $($headers[i]);
+ if ($.metadata && (h.metadata() && h.metadata().sorter)) {
+ p = getParserById(h.metadata().sorter);
} else if ((table.config.headers[i] && 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
- p = getParserById($($headers[i]).attr('class').match(/sorter-(\w+)/)[1] || '');
+ p = getParserById(h.attr('class').match(/sorter-(\w+)/)[1] || '');
}
if (!p) {
p = detectParserForColumn(table, rows, -1, i);
@@ -226,8 +227,9 @@
/* utils */
function buildCache(table) {
- var totalRows = (table.tBodies[0] && table.tBodies[0].rows.length) || 0,
- totalCells = (table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells.length) || 0,
+ var b = table.tBodies[0],
+ totalRows = (b && b.rows.length) || 0,
+ totalCells = (b.rows[0] && b.rows[0].cells.length) || 0,
parsers = table.config.parsers,
cache = {
row: [],
@@ -239,7 +241,7 @@
}
for (i = 0; i < totalRows; ++i) {
/** Add the table data to main data array */
- c = $(table.tBodies[0].rows[i]);
+ c = $(b.rows[i]);
cols = [];
// if this is a child row, add it to the last row's children and
// continue to the next row
Oops, something went wrong.

0 comments on commit 72f6213

Please sign in to comment.