#1680 closed defect (fixed)
dojo.i18n.number.format formatting String.substr problem
Reported by: | cazzius | Owned by: | Adam Peller |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | General | Version: | 0.4 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
In IE String.substr(start) start must be > 0.
Simple patch:
--- number.js (revision 6230) +++ number.js (working copy) @@ -38,10 +38,13 @@ // Splits str into substrings of size count, starting from right to left. Is there a more clever way to do this in JS? function splitSubstrings(str, count){ - for(var subs = []; str.length >= count; str = str.substr(0, str.length - count)){ - subs.push(str.substr(-count)); + var subs = []; + while (str.length >= count) { + var s = str.substr(str.length - count, count); + subs.push(s); + str = str.substr(0, str.length - count); } - if (str.length > 0){subs.push(str);} + if (str.length > 0) { subs.push(str); } return subs.reverse(); }
Change History (3)
comment:1 Changed 16 years ago by
Milestone: | → 0.5 |
---|---|
Owner: | changed from anonymous to Adam Peller |
comment:2 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
(In [6876]) Thanks for pointing out the substr problem, cazzius. Fixes #1680