r90630 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90629‎ | r90630 | r90631 >
Date:23:19, 22 June 2011
Author:brion
Status:resolved (Comments)
Tags:
Comment:
Followup r86088, r87244, r90612: fix jquery.tablesorter for null collation table on IE

Attempt to build a regex from an empty list failed when calling new RegEx('[]', 'ig') on IE 6/7/8.
Now allowing null for the object, and also not trying to create the regex even if we have an empty object just in case.
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.tablesorter.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.tablesorter.js
@@ -421,7 +421,7 @@
422422 // We allow a trailing percent sign, which we just strip. This works fine
423423 // if percents and regular numbers aren't being mixed.
424424 ts.numberRegex = new RegExp("^(" + "[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?" + // Fortran-style scientific
425 - "|" + "[-+\u2212]?" + digitClass + "+[\\s\\xa0]*%?" + // Generic localised
 425+ "|" + "[-+\u2212]?" + digitClass + "+[\\s]*%?" + // Generic localised
426426 ")$", "i");
427427 }
428428
@@ -470,16 +470,19 @@
471471
472472 function buildCollationTable() {
473473 ts.collationTable = mw.config.get('tableSorterCollation');
474 - if ( typeof ts.collationTable === "object" ) {
475 - ts.collationRegex = [];
 474+ ts.collationRegex = null;
 475+ if ( ts.collationTable ) {
 476+ var keys = [];
476477
477478 //Build array of key names
478479 for ( var key in ts.collationTable ) {
479480 if ( ts.collationTable.hasOwnProperty(key) ) { //to be safe
480 - ts.collationRegex.push(key);
 481+ keys.push(key);
481482 }
482483 }
483 - ts.collationRegex = new RegExp( '[' + ts.collationRegex.join('') + ']', 'ig' );
 484+ if (keys.length) {
 485+ ts.collationRegex = new RegExp( '[' + ts.collationRegex.join('') + ']', 'ig' );
 486+ }
484487 }
485488 }
486489

Follow-up revisions

RevisionCommit summaryAuthorDate
r90631Revert accidental change from r90630diebuche23:22, 22 June 2011
r90655Adding a collation test to tablesorter, fixing var ref from r90630diebuche07:39, 23 June 2011
r91782MFT to REL_1_18: jquery tablesorter...hashar08:54, 9 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86088Completely rewritten table sorting script....diebuche21:47, 14 April 2011
r87244Tablesorter: use mw.config.get() to access globals; force mdy for english con...diebuche11:55, 2 May 2011
r90612Fix tablesorting bug that caused weird interferences between two tables; Make...diebuche21:54, 22 June 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   00:12, 23 June 2011

Marking for merge to 1.18; fixes IE 6/7/8 regression.

#Comment by Brion VIBBER (talk | contribs)   20:10, 23 June 2011

r90655 has another fix needed to make the custom collation actually work -- I missed a spot in here!

Status & tagging log