r101417 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101416‎ | r101417 | r101418 >
Date:22:12, 31 October 2011
Author:krinkle
Status:ok
Tags:
Comment:
jquery.tablesorter: Selector fixes
* Various fixes to limit the selector to the current table and avoid selecting similar elements from other, nested, tables.
* Should fix bug 32049
* Follows-up r97150 and likely some other refactoring commits
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.tablesorter.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.tablesorter.js
@@ -230,7 +230,7 @@
231231 * @param $table jQuery object for a <table>
232232 */
233233 function emulateTHeadAndFoot( $table ) {
234 - var $rows = $table.find( 'tr' );
 234+ var $rows = $table.find( '> tbody > tr' );
235235 if( !$table.get(0).tHead ) {
236236 var $thead = $( '<thead>' );
237237 $rows.each( function() {
@@ -270,7 +270,7 @@
271271 });
272272 $tableHeaders = $( longest );
273273 }
274 - $tableHeaders = $tableHeaders.find( 'th' ).each( function( index ) {
 274+ $tableHeaders = $tableHeaders.children( 'th' ).each( function( index ) {
275275 this.column = realCellIndex;
276276
277277 var colspan = this.colspan;
@@ -442,13 +442,13 @@
443443
444444 function explodeRowspans( $table ) {
445445 // Split multi row cells into multiple cells with the same content
446 - $table.find( 'tbody [rowspan]' ).each(function() {
 446+ $table.find( '> tbody [rowspan]' ).each(function() {
447447 var rowSpan = this.rowSpan;
448448 this.rowSpan = 1;
449449 var cell = $( this );
450450 var next = cell.parent().nextAll();
451451 for ( var i = 0; i < rowSpan - 1; i++ ) {
452 - var td = next.eq( i ).find( 'td' );
 452+ var td = next.eq( i ).children( 'td' );
453453 if ( !td.length ) {
454454 next.eq( i ).append( cell.clone() );
455455 } else if ( this.cellIndex === 0 ) {
@@ -599,10 +599,10 @@
600600 // Legacy fix of .sortbottoms
601601 // Wrap them inside inside a tfoot (because that's what they actually want to be) &
602602 // and put the <tfoot> at the end of the <table>
603 - var $sortbottoms = $table.find( 'tr.sortbottom' );
 603+ var $sortbottoms = $table.find( '> tbody > tr.sortbottom' );
604604 if ( $sortbottoms.length ) {
605 - var $tfoot = $table.find( 'tfoot' );
606 - if( $tfoot.length ) {
 605+ var $tfoot = $table.children( 'tfoot' );
 606+ if ( $tfoot.length ) {
607607 $tfoot.eq(0).prepend( $sortbottoms );
608608 } else {
609609 $table.append( $( '<tfoot>' ).append( $sortbottoms ) )

Follow-up revisions

RevisionCommit summaryAuthorDate
r101420jquery.tablesorter: More selector fixes...krinkle22:20, 31 October 2011
r102533REL1_18: MFT r101314, r101370, r101376, r101417, r101420, r101445, r101464, r...reedy17:04, 9 November 2011
r1025931.18wmf1 MFT r101417, r101420, r101540reedy23:05, 9 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97150Update jquery.tablesorter for r97145: emulate <thead> if there is no <thead> ...catrope13:15, 15 September 2011

Status & tagging log