Skip to content

Commit 738a80e

Browse files
committed
fix #347 currency filter with string values
1 parent b9ab204 commit 738a80e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/filters.js

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ filters.lowercase = function (value) {
3535
* 12345 => $12,345.00
3636
*/
3737
filters.currency = function (value, sign) {
38+
value = parseFloat(value)
3839
if (!value && value !== 0) return ''
3940
sign = sign || '$'
4041
var s = Math.floor(value).toString(),

test/unit/specs/filters.js

+7
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ describe('Filters', function () {
9898
assert.strictEqual(res4, '$0.00')
9999
})
100100

101+
it('should cast strings into float', function () {
102+
var res1 = filter('fesf'),
103+
res2 = filter('0.24')
104+
assert.strictEqual(res1, '')
105+
assert.strictEqual(res2, '$0.24')
106+
})
107+
101108
})
102109

103110
describe('key', function () {

0 commit comments

Comments
 (0)