Skip to content

Commit 0ceb36c

Browse files
authored
Merge pull request #29 from morloderex/morloderex-seperator-watcher
Add a watcher for seperator prop
2 parents dc28b47 + 2353737 commit 0ceb36c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/vue-numeric.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ export default {
262262
this.$refs.readOnly.className = this.readOnlyClass
263263
})
264264
}
265+
},
266+
267+
/**
268+
* Immediately reflect separator changes
269+
*/
270+
separator () {
271+
this.process(this.valueNumber)
272+
this.amount = this.format(this.valueNumber)
265273
}
266274
},
267275

test/specs/vue-numeric.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,10 @@ describe('vue-numeric.vue', () => {
206206
const wrapper = mount(component)
207207
expect(wrapper.data().total).to.equal(0)
208208
})
209+
210+
it('apply new separator immediately if it is changed', () => {
211+
const wrapper = mount(VueNumeric, { propsData: { value: 2000, separator: "," } })
212+
wrapper.setProps({ separator: "." })
213+
expect(wrapper.data().amount).to.equal("2.000")
214+
})
209215
})

0 commit comments

Comments
 (0)