Skip to content

Commit b3b3011

Browse files
committed
fix the issue of updated global config by component
1 parent 38ca543 commit b3b3011

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/component.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
<script>
1616
import directive from './directive'
17-
import options from './options'
17+
import { cloneDeep } from "./core";
18+
import defaultOptions from './options'
19+
20+
const options = cloneDeep(defaultOptions)
1821
1922
export default {
2023
props: {

src/core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import NumberFormat from './number-format'
33

44
export const CONFIG_KEY = '__input-facade__'
55

6+
/**
7+
* Creates a fuction to clone the objcet
8+
*/
9+
export function cloneDeep(data) {
10+
return JSON.parse(JSON.stringify(data))
11+
}
12+
613
/**
714
* Creates a CustomEvent('input') with detail = { facade: true }
815
* used as a way to identify our own input event

src/directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default {
3434
if (([110, 190].includes(e.keyCode) || e.key === config.decimal) && !el.value.includes(config.decimal)) {
3535
e.preventDefault()
3636
el.setRangeText(config.decimal)
37-
el.dispatchEvent(new Event('input'))
37+
core.updateValue(el, null, { emit: true }, e)
3838
core.updateCursor(el, el.value.indexOf(config.decimal) + 1)
3939
} else if (([110, 190].includes(e.keyCode) || e.key === config.decimal) && el.value.includes(config.decimal)) {
4040
e.preventDefault()

0 commit comments

Comments
 (0)