r40379 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40378‎ | r40379 | r40380 >
Date:13:45, 3 September 2008
Author:simetrical
Status:old
Tags:
Comment:
Use ECMAScript standard, section 9.3, to decide what's a number

r40348 was kind of broken, in terms of considering strings like "e" to be numbers. The version before that would also act incorrectly for strings like ".".
Modified paths:
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -616,7 +616,11 @@
617617 // pound dollar euro yen currency cents
618618 else if (itm.match(/(^[\u00a3$\u20ac\u00a4\u00a5]|\u00a2$)/))
619619 sortfn = ts_sort_currency;
620 - else if (itm.match(/^[\d.,eE+-]+\%?$/))
 620+ // We allow a trailing percent sign, which we just strip. This works fine
 621+ // if percents and regular numbers aren't being mixed.
 622+ else if (itm.match(/^[+-]?[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?\%?$/) ||
 623+ itm.match(/^[+-]?\.[0-9]+([eE][+-]?[0-9]+)?\%?$/) ||
 624+ itm.match(/^0[xX][0-9a-fA-F]+$/))
621625 sortfn = ts_sort_numeric;
622626
623627 var reverse = (span.getAttribute("sortdir") == 'down');

Follow-up revisions

RevisionCommit summaryAuthorDate
r40382Fix for r40379, allow commas againsimetrical14:02, 3 September 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r40348(bug 15422) Sort more types of numbers in sortable tables...simetrical00:16, 3 September 2008