@@ -5,7 +5,7 @@ export default function (el, binding) {
55 const { value } = binding
66 if ( ! value ) return false
77 const config = Object . assign ( options , value )
8- // console.log('src/components/directive:config ', config)
8+ // console.log('src/components/directive:init() ', config)
99
1010 // v-number used on a component that's not a input element
1111 if ( el . localName !== 'input' ) {
@@ -21,28 +21,29 @@ export default function (el, binding) {
2121 el . setAttribute ( 'type' , 'text' )
2222
2323 el . oninput = ( ) => {
24- // console.log('oninput()')
24+ // console.log('src/directive.js: oninput()', evt )
2525 var positionFromEnd = el . value . length - el . selectionEnd
2626 el . value = new NumberFormat ( config ) . format ( el . value )
2727 positionFromEnd = Math . max ( positionFromEnd , config . suffix . length )
2828 positionFromEnd = el . value . length - positionFromEnd
2929 positionFromEnd = Math . max ( positionFromEnd , config . prefix . length + 1 )
3030 setCursor ( el , positionFromEnd )
31- // el.dispatchEvent(new Event('change'))
3231 }
3332
3433 el . onblur = ( ) => {
3534 // clean up after end the input
35+ // console.log('src/directive.js:onblur()')
3636 el . value = new NumberFormat ( config ) . clean ( ) . format ( el . value )
3737 el . dispatchEvent ( new Event ( 'change' ) )
3838 }
3939
4040 el . onfocus = ( ) => {
41- // console.log('onfocus()')
41+ // console.log('src/directive.js: onfocus()')
4242 setCursor ( el , el . value . length - config . suffix . length )
4343 }
4444
4545 el . onkeydown = ( evt ) => {
46+ // console.log('src/directive.js:onkeydown()')
4647 // Check deciaml
4748 if ( evt . key === config . decimal && evt . target . value . includes ( config . decimal ) ) {
4849 evt . preventDefault ( )
@@ -75,5 +76,4 @@ export default function (el, binding) {
7576 // force format after initialization
7677 el . oninput ( )
7778 el . dispatchEvent ( new Event ( 'input' ) )
78- el . dispatchEvent ( new Event ( 'change' ) )
7979}
0 commit comments