@@ -5,7 +5,7 @@ export default function (el, binding) {
5
5
const { value } = binding
6
6
if ( ! value ) return false
7
7
const config = Object . assign ( options , value )
8
- // console.log('src/components/directive:config ', config)
8
+ // console.log('src/components/directive:init() ', config)
9
9
10
10
// v-number used on a component that's not a input element
11
11
if ( el . localName !== 'input' ) {
@@ -21,28 +21,29 @@ export default function (el, binding) {
21
21
el . setAttribute ( 'type' , 'text' )
22
22
23
23
el . oninput = ( ) => {
24
- // console.log('oninput()')
24
+ // console.log('src/directive.js: oninput()', evt )
25
25
var positionFromEnd = el . value . length - el . selectionEnd
26
26
el . value = new NumberFormat ( config ) . format ( el . value )
27
27
positionFromEnd = Math . max ( positionFromEnd , config . suffix . length )
28
28
positionFromEnd = el . value . length - positionFromEnd
29
29
positionFromEnd = Math . max ( positionFromEnd , config . prefix . length + 1 )
30
30
setCursor ( el , positionFromEnd )
31
- // el.dispatchEvent(new Event('change'))
32
31
}
33
32
34
33
el . onblur = ( ) => {
35
34
// clean up after end the input
35
+ // console.log('src/directive.js:onblur()')
36
36
el . value = new NumberFormat ( config ) . clean ( ) . format ( el . value )
37
37
el . dispatchEvent ( new Event ( 'change' ) )
38
38
}
39
39
40
40
el . onfocus = ( ) => {
41
- // console.log('onfocus()')
41
+ // console.log('src/directive.js: onfocus()')
42
42
setCursor ( el , el . value . length - config . suffix . length )
43
43
}
44
44
45
45
el . onkeydown = ( evt ) => {
46
+ // console.log('src/directive.js:onkeydown()')
46
47
// Check deciaml
47
48
if ( evt . key === config . decimal && evt . target . value . includes ( config . decimal ) ) {
48
49
evt . preventDefault ( )
@@ -75,5 +76,4 @@ export default function (el, binding) {
75
76
// force format after initialization
76
77
el . oninput ( )
77
78
el . dispatchEvent ( new Event ( 'input' ) )
78
- el . dispatchEvent ( new Event ( 'change' ) )
79
79
}
0 commit comments