@@ -47,30 +47,36 @@ 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
- 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 )
50
+ this . listener = this . filters
51
+ ? 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
+ _ . nextTick ( function ( ) {
62
+ // force a value update, because in
63
+ // certain cases the write filters output the
64
+ // same result for different input values, and
65
+ // the Observer set events won't be triggered.
66
+ var newVal = self . _watcher . value
67
+ self . update ( newVal )
68
+ if ( charsOffset != null ) {
69
+ var cursorPos =
70
+ _ . toString ( newVal ) . length - charsOffset
71
+ el . setSelectionRange ( cursorPos , cursorPos )
72
+ }
73
+ } )
71
74
}
72
- } )
73
- }
75
+ : function textInputListener ( ) {
76
+ if ( cpLocked ) return
77
+ set ( )
78
+ }
79
+
74
80
this . event = lazy ? 'change' : 'input'
75
81
_ . on ( el , this . event , this . listener )
76
82
0 commit comments