From: Brion Vibber Date: Wed, 22 Jun 2011 23:19:00 +0000 (+0000) Subject: Followup r86088, r87244, r90612: fix jquery.tablesorter for null collation table... X-Git-Tag: 1.31.0-rc.0~29340 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=ec84480c18fe55cbfd2b7879f83b6fbf0d45520c;p=lhc%2Fweb%2Fwiklou.git 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. --- 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' ); + } } }