From c9f4643970322529b0ab4a75f900bb4ad1ba35fb Mon Sep 17 00:00:00 2001 From: Matthew Chambers Date: Tue, 26 Jun 2018 12:09:37 -0400 Subject: [PATCH 1/2] Missing defaults no longer cause errors --- src/VueIntlNumberformat.vue | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/VueIntlNumberformat.vue b/src/VueIntlNumberformat.vue index 189cbd0..f1b726e 100644 --- a/src/VueIntlNumberformat.vue +++ b/src/VueIntlNumberformat.vue @@ -30,12 +30,19 @@ export default { }, computed: { localeString() { - const t = this; - return new Intl.NumberFormat(`${t.locale}`, { - style: `${t.formatStyle}`, - currency: `${t.currency}`, - maximumSignificantDigits: t.maxDigits, - }).format(t.number); + let options = { + style: this.formatStyle, + }; + + if ('currency' in this) { + options.currency = this.currency; + } + + if ('currency' in this) { + options.maximumSignificantDigits = this.maxDigits; + } + + return new Intl.NumberFormat(`${this.locale}`, options).format(this.number); }, }, }; From 0299750895e5925d55d40519b71c76838d44d3cc Mon Sep 17 00:00:00 2001 From: Matthew Chambers Date: Tue, 26 Jun 2018 12:26:52 -0400 Subject: [PATCH 2/2] Typo --- src/VueIntlNumberformat.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VueIntlNumberformat.vue b/src/VueIntlNumberformat.vue index f1b726e..616eb00 100644 --- a/src/VueIntlNumberformat.vue +++ b/src/VueIntlNumberformat.vue @@ -38,7 +38,7 @@ export default { options.currency = this.currency; } - if ('currency' in this) { + if ('maximumSignificantDigits' in this) { options.maximumSignificantDigits = this.maxDigits; }