jquery.tablesorter: Selector fixes
authorKrinkle <krinkle@users.mediawiki.org>
Mon, 31 Oct 2011 22:12:26 +0000 (22:12 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Mon, 31 Oct 2011 22:12:26 +0000 (22:12 +0000)
* 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

resources/jquery/jquery.tablesorter.js

index 443024b..97c7baf 100644 (file)
         * @param $table jQuery object for a <table>
         */ 
        function emulateTHeadAndFoot( $table ) {
-               var $rows = $table.find( 'tr' );
+               var $rows = $table.find( '> tbody > tr' );
                if( !$table.get(0).tHead ) {
                        var $thead = $( '<thead>' );
                        $rows.each( function() {
                        });
                        $tableHeaders = $( longest );
                }
-               $tableHeaders = $tableHeaders.find( 'th' ).each( function( index ) {
+               $tableHeaders = $tableHeaders.children( 'th' ).each( function( index ) {
                        this.column = realCellIndex;
 
                        var colspan = this.colspan;
 
        function explodeRowspans( $table ) {
                // Split multi row cells into multiple cells with the same content
-               $table.find( 'tbody [rowspan]' ).each(function() {
+               $table.find( 'tbody [rowspan]' ).each(function() {
                        var rowSpan = this.rowSpan;
                        this.rowSpan = 1;
                        var cell = $( this );
                        var next = cell.parent().nextAll();
                        for ( var i = 0; i < rowSpan - 1; i++ ) {
-                               var td = next.eq( i ).find( 'td' );
+                               var td = next.eq( i ).children( 'td' );
                                if ( !td.length ) {
                                        next.eq( i ).append( cell.clone() );
                                } else if ( this.cellIndex === 0 ) {
                                                        // Legacy fix of .sortbottoms
                                                        // Wrap them inside inside a tfoot (because that's what they actually want to be) &
                                                        // and put the <tfoot> at the end of the <table>
-                                                       var $sortbottoms = $table.find( 'tr.sortbottom' );
+                                                       var $sortbottoms = $table.find( '> tbody > tr.sortbottom' );
                                                        if ( $sortbottoms.length ) {
-                                                               var $tfoot = $table.find( 'tfoot' );
-                                                               if( $tfoot.length ) {
+                                                               var $tfoot = $table.children( 'tfoot' );
+                                                               if ( $tfoot.length ) {
                                                                        $tfoot.eq(0).prepend( $sortbottoms );
                                                                } else {
                                                                        $table.append( $( '<tfoot>' ).append( $sortbottoms ) )