@@ -17,6 +17,7 @@ export default {
1717 el = core . getInputElement ( el )
1818 const option = el [ CONFIG_KEY ]
1919 const { config } = option
20+
2021 // prefer adding event listener to parent element to avoid Firefox bug which does not
2122 // execute `useCapture: true` event handlers before non-capturing event handlers
2223 const handlerOwner = el . parentElement || el
@@ -36,9 +37,12 @@ export default {
3637 // check decimal key and insert to current element
3738 // updated cursor position after format the value
3839 el . onkeydown = ( e ) => {
40+ const { target } = e
41+ const regExp = new RegExp ( `${ config . prefix } |${ config . suffix } ` , 'g' )
42+ let newValue = target . value . replace ( regExp , '' )
3943 if (
4044 ( [ 110 , 190 ] . includes ( e . keyCode ) || e . key === config . decimal ) &&
41- el . value . includes ( config . decimal )
45+ newValue . includes ( config . decimal )
4246 ) {
4347 e . preventDefault ( )
4448 } else if ( [ 8 ] . includes ( e . keyCode ) ) {
@@ -72,9 +76,9 @@ export default {
7276
7377 updated : ( el , { value, oldValue, modifiers } , vnode ) => {
7478 el = core . getInputElement ( el )
79+ const { config } = el [ CONFIG_KEY ]
80+ el [ CONFIG_KEY ] . config = Object . assign ( { } , config , value , modifiers )
7581 if ( value !== oldValue ) {
76- const { config } = el [ CONFIG_KEY ]
77- el [ CONFIG_KEY ] . config = Object . assign ( { } , config , value , modifiers )
7882 core . updateValue ( el , vnode , { force : true , clean : true } )
7983 } else {
8084 core . updateValue ( el , vnode )
0 commit comments