From ec84480c18fe55cbfd2b7879f83b6fbf0d45520c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 22 Jun 2011 23:19:00 +0000 Subject: [PATCH] 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. --- resources/jquery/jquery.tablesorter.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/resources/jquery/jquery.tablesorter.js b/resources/jquery/jquery.tablesorter.js index b443eb125b..f12ee0dce2 100644 --- a/resources/jquery/jquery.tablesorter.js +++ b/resources/jquery/jquery.tablesorter.js @@ -421,7 +421,7 @@ // We allow a trailing percent sign, which we just strip. This works fine // if percents and regular numbers aren't being mixed. ts.numberRegex = new RegExp("^(" + "[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?" + // Fortran-style scientific - "|" + "[-+\u2212]?" + digitClass + "+[\\s\\xa0]*%?" + // Generic localised + "|" + "[-+\u2212]?" + digitClass + "+[\\s]*%?" + // Generic localised ")$", "i"); } @@ -470,16 +470,19 @@ function buildCollationTable() { ts.collationTable = mw.config.get('tableSorterCollation'); - if ( typeof ts.collationTable === "object" ) { - ts.collationRegex = []; + ts.collationRegex = null; + if ( ts.collationTable ) { + var keys = []; //Build array of key names for ( var key in ts.collationTable ) { if ( ts.collationTable.hasOwnProperty(key) ) { //to be safe - ts.collationRegex.push(key); + keys.push(key); } } - ts.collationRegex = new RegExp( '[' + ts.collationRegex.join('') + ']', 'ig' ); + if (keys.length) { + ts.collationRegex = new RegExp( '[' + ts.collationRegex.join('') + ']', 'ig' ); + } } } -- 2.20.1