diff --git a/src/vue-numeric.vue b/src/vue-numeric.vue index 3702dce..f2af4d1 100644 --- a/src/vue-numeric.vue +++ b/src/vue-numeric.vue @@ -263,8 +263,13 @@ export default { }) } }, - - separator(newValue, oldValue) { + + /** + * Immediately reflect separator changes + * @param {String} newValue + * @param {String} oldValue + */ + separator (newValue, oldValue) { if (newValue !== oldValue) { this.process(this.valueNumber) this.amount = this.format(this.valueNumber) diff --git a/test/specs/vue-numeric.spec.js b/test/specs/vue-numeric.spec.js index 2aab62f..40ec775 100644 --- a/test/specs/vue-numeric.spec.js +++ b/test/specs/vue-numeric.spec.js @@ -206,4 +206,10 @@ describe('vue-numeric.vue', () => { const wrapper = mount(component) expect(wrapper.data().total).to.equal(0) }) + + it('apply new separator immediately if it is changed', () => { + const wrapper = mount(VueNumeric, { propsData: { value: 2000, separator: "," } }) + wrapper.setProps({ separator: "." }) + expect(wrapper.data().amount).to.equal("2.000") + }) })