MatthiasDD has uploaded a new change for review.
https://gerrit.wikimedia.org/r/244940
Change subject: jquery.tablesorter: use of expand-child class
......................................................................
jquery.tablesorter: use of expand-child class
Rows with class expand-child are now scipped in detectParserForColumn().
This is necessary after change I5180296.
Add a test for expand-child class.
Bug: T114721
Change-Id: I88a01208889fbb461b1f42855ed6494d479440fa
---
M resources/src/jquery/jquery.tablesorter.js
M tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
2 files changed, 39 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/40/244940/1
diff --git a/resources/src/jquery/jquery.tablesorter.js
b/resources/src/jquery/jquery.tablesorter.js
index 0eefae6..4a78588 100644
--- a/resources/src/jquery/jquery.tablesorter.js
+++ b/resources/src/jquery/jquery.tablesorter.js
@@ -107,6 +107,7 @@
function detectParserForColumn( table, rows, column ) {
var l = parsers.length,
+ config = $( table ).data( 'tablesorter' ).config,
cellIndex,
nodeValue,
// Start with 1 because 0 is the fallback parser
@@ -118,7 +119,8 @@
needed = ( rows.length > 4 ) ? 5 : rows.length;
while ( i < l ) {
- if ( rows[ rowIndex ] ) {
+ // if this is a child row, continue to the next row (as
buildCache())
+ if ( rows[ rowIndex ] && !$( rows[ rowIndex ]
).hasClass( config.cssChildRow ) ) {
if ( rowIndex !== lastRowIndex ) {
lastRowIndex = rowIndex;
cellIndex = $( rows[ rowIndex ] ).data(
'columnToCell' )[ column ];
diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
index 6805eab..bc64809 100644
--- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
+++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
@@ -1423,6 +1423,41 @@
0,
'empty cell is sorted as number 0'
);
-
} );
+
+ QUnit.test( 'bug 114721 - use of expand-child class', 2, function (
assert ) {
+ var $table, parsers;
+ $table = $(
+ '<table class="sortable">' +
+ '<tr><th>A</th><th>B</th></tr>' +
+ '<tr><td>b</td><td>4</td></tr>' +
+ '<tr class="expand-child"><td colspan="2">some
text follow b</td></tr>' +
+ '<tr><td>a</td><td>2</td></tr>' +
+ '<tr class="expand-child"><td colspan="2">some
text follow a</td></tr>' +
+ '<tr class="expand-child"><td colspan="2">more
text</td></tr>' +
+ '</table>'
+ );
+ $table.tablesorter();
+ $table.find( '.headerSort:eq(0)' ).click();
+
+ assert.deepEqual(
+ tableExtract( $table ),
+ [
+ [ 'a', '2' ],
+ [ 'some text follow a' ],
+ [ 'more text' ],
+ [ 'b', '4' ],
+ [ 'some text follow b' ]
+ ],
+ 'row with expand-child class follow above row'
+ );
+
+ parsers = $table.data( 'tablesorter' ).config.parsers;
+ assert.equal(
+ parsers[ 1 ].id,
+ 'number',
+ 'detectParserForColumn() detect parser.id "number" for
second column'
+ );
+ } );
+
}( jQuery, mediaWiki ) );
--
To view, visit https://gerrit.wikimedia.org/r/244940
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I88a01208889fbb461b1f42855ed6494d479440fa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MatthiasDD <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits