mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Core: allow empty string in textExtraction data-attribute. See #954
This commit is contained in:
parent
c808f83df1
commit
37d44b18e3
8
dist/js/jquery.tablesorter.js
vendored
8
dist/js/jquery.tablesorter.js
vendored
@ -201,10 +201,10 @@
|
||||
if (typeof(t) === 'string') {
|
||||
// check data-attribute first when set to 'basic'; don't use node.innerText - it's really slow!
|
||||
// http://www.kellegous.com/j/2013/02/27/innertext-vs-textcontent/
|
||||
return $.trim(
|
||||
( t === 'basic' ? $node.attr(c.textAttribute) || node.textContent : node.textContent ) ||
|
||||
$node.text()
|
||||
);
|
||||
if ( t === 'basic' && typeof ( te = $node.attr(c.textAttribute) ) !== 'undefined' ) {
|
||||
return $.trim( te );
|
||||
}
|
||||
return $.trim( node.textContent || $node.text() );
|
||||
} else {
|
||||
if (typeof(t) === 'function') {
|
||||
return $.trim( t($node[0], c.table, cellIndex) );
|
||||
|
2
dist/js/jquery.tablesorter.min.js
vendored
2
dist/js/jquery.tablesorter.min.js
vendored
File diff suppressed because one or more lines are too long
@ -191,10 +191,10 @@
|
||||
if (typeof(t) === 'string') {
|
||||
// check data-attribute first when set to 'basic'; don't use node.innerText - it's really slow!
|
||||
// http://www.kellegous.com/j/2013/02/27/innertext-vs-textcontent/
|
||||
return $.trim(
|
||||
( t === 'basic' ? $node.attr(c.textAttribute) || node.textContent : node.textContent ) ||
|
||||
$node.text()
|
||||
);
|
||||
if ( t === 'basic' && typeof ( te = $node.attr(c.textAttribute) ) !== 'undefined' ) {
|
||||
return $.trim( te );
|
||||
}
|
||||
return $.trim( node.textContent || $node.text() );
|
||||
} else {
|
||||
if (typeof(t) === 'function') {
|
||||
return $.trim( t($node[0], c.table, cellIndex) );
|
||||
|
@ -53,6 +53,7 @@
|
||||
<tr><td colspan="2">Info</td></tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr><td data-text="">ignored</td><td>x0</td></tr>
|
||||
<tr><td>testB</td><td>x5</td></tr>
|
||||
<tr><td>testC</td><td>x4</td></tr>
|
||||
<tr><td>testA</td><td>x6</td></tr>
|
||||
|
@ -476,7 +476,7 @@ $(function(){
|
||||
|
||||
$table1.trigger('sorton', [[[ 0,0 ]]]);
|
||||
assert.cacheCompare( table1, 0, [ 'test1', 'test2', 'test3',
|
||||
'testa', 'testb', 'testc' ], 'from data-attribute' );
|
||||
'testa', 'testb', 'testc', '' ], 'from data-attribute' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 0,1 ]]]);
|
||||
assert.cacheCompare( table3, 0, [ '', 'a255', 'a102', 'a87', 'a55', 'a43', 'a33', 'a10', 'a02', 'a1' ], 'ignore data-attribute' );
|
||||
@ -496,15 +496,15 @@ $(function(){
|
||||
|
||||
// lower case because table was parsed before c1.ignoreCase was changed
|
||||
assert.cacheCompare( table1, 'all', [ 'test2', 'x2', 'test1', 'x3', 'test3', 'x1',
|
||||
'testb', 'x5', 'testc', 'x4', 'testa', 'x6' ], 'unsorted' );
|
||||
'', 'x0', 'testb', 'x5', 'testc', 'x4', 'testa', 'x6' ], 'unsorted' );
|
||||
|
||||
$table1.trigger('sorton', [[[ 0,0 ]]]);
|
||||
assert.cacheCompare( table1, 'all', [ 'test1', 'x3', 'test2', 'x2', 'test3', 'x1',
|
||||
'testa', 'x6', 'testb', 'x5', 'testc', 'x4' ], 'ascending sort' );
|
||||
'testa', 'x6', 'testb', 'x5', 'testc', 'x4', '', 'x0' ], 'ascending sort' );
|
||||
|
||||
$table1.trigger('sorton', [[[ 0,1 ]]]);
|
||||
assert.cacheCompare( table1, 'all', [ 'test3', 'x1', 'test2', 'x2', 'test1', 'x3',
|
||||
'testc', 'x4', 'testb', 'x5', 'testa', 'x6' ], 'descending sort' );
|
||||
'testc', 'x4', 'testb', 'x5', 'testa', 'x6', '', 'x0' ], 'descending sort' );
|
||||
|
||||
// empty cell position
|
||||
$table3.trigger('sorton', [[[ 0,0 ]]]);
|
||||
@ -626,7 +626,7 @@ $(function(){
|
||||
p1 = c1.parsers[1].id === 'digit';
|
||||
assert.equal(hc && hd && hl && p1, true, 'testing header cache: updateAll - thead');
|
||||
assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3,
|
||||
'testc', 4, 'testb', 5, 'testa', 6 ], 'updateAll - tbody' );
|
||||
'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'updateAll - tbody' );
|
||||
}]);
|
||||
|
||||
// addRows
|
||||
@ -637,7 +637,7 @@ $(function(){
|
||||
updateCallback++;
|
||||
assert.equal( oldColMax === 6 && c1.cache[1].colMax[1] === 7, true, 'addRows includes updating colMax value');
|
||||
assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3,
|
||||
'testd', 7, 'testc', 4, 'testb', 5, 'testa', 6 ], 'addRows method' );
|
||||
'testd', 7, 'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'addRows method' );
|
||||
}]);
|
||||
|
||||
// updateCell
|
||||
@ -648,7 +648,7 @@ $(function(){
|
||||
updateCallback++;
|
||||
assert.equal( oldColMax === 7 && c1.cache[1].colMax[1] === 8, true, 'updateCell includes updating colMax value');
|
||||
assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3,
|
||||
'testd', -8, 'testc', 4, 'testb', 5, 'testa', 6 ], 'updateCell method' );
|
||||
'testd', -8, 'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'updateCell method' );
|
||||
}]);
|
||||
|
||||
// update
|
||||
@ -658,7 +658,7 @@ $(function(){
|
||||
updateCallback++;
|
||||
assert.equal( oldColMax === 8 && c1.cache[1].colMax[1] === 6, true, 'update includes updating colMax value');
|
||||
assert.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3,
|
||||
'testc', 4, 'testb', 5, 'testa', 6 ], 'update method' );
|
||||
'testc', 4, 'testb', 5, 'testa', 6, '', 0 ], 'update method' );
|
||||
}]);
|
||||
|
||||
$table5
|
||||
|
Loading…
Reference in New Issue
Block a user