Skip to content

Commit 896cfcf

Browse files
Support no-symbol on currency filter (closes vuejs#1131)
1 parent 9e25f05 commit 896cfcf

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/filters/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var digitsRE = /(\d{3})(?=\d)/g
6161
exports.currency = function (value, currency) {
6262
value = parseFloat(value)
6363
if (!isFinite(value) || (!value && value !== 0)) return ''
64-
currency = currency || '$'
64+
currency = currency != null ? currency : '$'
6565
var stringified = Math.abs(value).toFixed(2)
6666
var _int = stringified.slice(0, -3)
6767
var i = _int.length % 3

test/unit/specs/filters/filters_spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ describe('Filters', function () {
6666
expect(filter(0.76)).toBe('$0.76')
6767
// sign arg
6868
expect(filter(2134, '@')).toBe('@2,134.00')
69+
// no symbol
70+
expect(filter(2134, '')).toBe('2,134.00')
6971
// falsy, infinity and 0
7072
expect(filter(0)).toBe('$0.00')
7173
expect(filter(false)).toBe('')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy