@@ -47,35 +47,29 @@ module.exports = {
47
47
// if the directive has filters, we need to
48
48
// record cursor position and restore it after updating
49
49
// the input with the filtered value.
50
- if ( this . filters ) {
51
- this . listener = function textInputListener ( ) {
52
- if ( cpLocked ) return
53
- var charsOffset
54
- // some HTML5 input types throw error here
55
- try {
56
- // record how many chars from the end of input
57
- // the cursor was at
58
- charsOffset = el . value . length - el . selectionStart
59
- } catch ( e ) { }
60
- set ( )
61
- // force a value update, because in
62
- // certain cases the write filters output the same
63
- // result for different input values, and the Observer
64
- // set events won't be triggered.
65
- _ . nextTick ( function ( ) {
66
- var newVal = self . _watcher . value
67
- self . update ( newVal )
68
- if ( charsOffset != null ) {
69
- var cursorPos = newVal . length - charsOffset
70
- el . setSelectionRange ( cursorPos , cursorPos )
71
- }
72
- } )
73
- }
74
- } else {
75
- this . listener = function textInputListener ( ) {
76
- if ( cpLocked ) return
77
- set ( )
78
- }
50
+ this . listener = function textInputListener ( ) {
51
+ if ( cpLocked ) return
52
+ var charsOffset
53
+ // some HTML5 input types throw error here
54
+ try {
55
+ // record how many chars from the end of input
56
+ // the cursor was at
57
+ charsOffset = el . value . length - el . selectionStart
58
+ } catch ( e ) { }
59
+ set ( )
60
+ // force a value update, because in
61
+ // certain cases the write filters output the same
62
+ // result for different input values, and the Observer
63
+ // set events won't be triggered.
64
+ _ . nextTick ( function ( ) {
65
+ var newVal = self . _watcher . value
66
+ self . update ( newVal )
67
+ if ( charsOffset != null ) {
68
+ var cursorPos =
69
+ _ . toString ( newVal ) . length - charsOffset
70
+ el . setSelectionRange ( cursorPos , cursorPos )
71
+ }
72
+ } )
79
73
}
80
74
this . event = lazy ? 'change' : 'input'
81
75
_ . on ( el , this . event , this . listener )
0 commit comments