Bartosz Dziewoński has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/303233

Change subject: jquery.tablesorter: Handle more than single characters in 
'tableSorterCollation'
......................................................................

jquery.tablesorter: Handle more than single characters in 'tableSorterCollation'

The code that uses this will already work fine, we only need to change
how the regex is built.

Bug: T140240
Change-Id: I014d9b13815d8ae085a6ed7c6df2d62337bb46f7
---
M resources/src/jquery/jquery.tablesorter.js
M tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
2 files changed, 36 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/33/303233/1

diff --git a/resources/src/jquery/jquery.tablesorter.js 
b/resources/src/jquery/jquery.tablesorter.js
index 50bfa87..62be0d8 100644
--- a/resources/src/jquery/jquery.tablesorter.js
+++ b/resources/src/jquery/jquery.tablesorter.js
@@ -696,11 +696,11 @@
                        for ( key in ts.collationTable ) {
                                // Check hasOwn to be safe
                                if ( ts.collationTable.hasOwnProperty( key ) ) {
-                                       keys.push( key );
+                                       keys.push( mw.RegExp.escape( key ) );
                                }
                        }
                        if ( keys.length ) {
-                               ts.collationRegex = new RegExp( '[' + 
keys.join( '' ) + ']', 'ig' );
+                               ts.collationRegex = new RegExp( keys.join( '|' 
), 'ig' );
                        }
                }
        }
diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js 
b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
index b09bb28..12f35ef 100644
--- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
+++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
@@ -81,6 +81,24 @@
                        [ 'Strasse' ]
                ],
 
+               // Data set "digraph"
+               digraphWords = [
+                       [ 'London' ],
+                       [ 'Ljubljana' ],
+                       [ 'Luxembourg' ],
+                       [ 'Njivice' ],
+                       [ 'Norwich' ]
+                       [ 'New York' ]
+               ],
+               digraphWordsSorted = [
+                       [ 'London' ],
+                       [ 'Luxembourg' ],
+                       [ 'Ljubljana' ],
+                       [ 'New York' ],
+                       [ 'Norwich' ],
+                       [ 'Njivice' ]
+               ],
+
                complexMDYDates = [
                        [ 'January, 19 2010' ],
                        [ 'April 21 1991' ],
@@ -697,6 +715,22 @@
                }
        );
 
+       tableTest(
+               'Digraphs with custom collation',
+               [ 'City' ],
+               digraphWords,
+               digraphWordsSorted,
+               function ( $table ) {
+                       mw.config.set( 'tableSorterCollation', {
+                               lj: 'lzzzz',
+                               nj: 'nzzzz'
+                       } );
+
+                       $table.tablesorter();
+                       $table.find( '.headerSort:eq(0)' ).click();
+               }
+       );
+
        QUnit.test( 'Rowspan not exploded on init', 1, function ( assert ) {
                var $table = tableCreate( header, planets );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/303233
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I014d9b13815d8ae085a6ed7c6df2d62337bb46f7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to