From: jenkins-bot Date: Tue, 13 Oct 2015 19:55:12 +0000 (+0000) Subject: Merge "jquery.tablesorter: use of expand-child class" X-Git-Tag: 1.31.0-rc.0~9413 X-Git-Url: https://git.heureux-cyclage.org/index.php?a=commitdiff_plain;h=bffc8e0bf360b896dcfa61b4f5d717f1c929b4fa;hp=25d8043356b9be5557d37f56c3c7f26de0e927c2;p=lhc%2Fweb%2Fwiklou.git Merge "jquery.tablesorter: use of expand-child class" --- diff --git a/resources/src/jquery/jquery.tablesorter.js b/resources/src/jquery/jquery.tablesorter.js index 69f8dd8ae4..f8216c97a0 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 6805eabc23..b09bb2825b 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 T114721 - use of expand-child class', 2, function ( assert ) { + var $table, parsers; + $table = $( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
AB
b4
some text follow b
a2
some text follow a
more text
' + ); + $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 ) );