File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,29 @@ module.exports = {
26
26
: 'value'
27
27
28
28
// attach listener
29
- self . set = function ( ) {
30
- self . vm . $set ( self . key , el [ attr ] )
31
- }
29
+ self . set = self . filters
30
+ ? function ( ) {
31
+ // if this directive has filters
32
+ // we need to let the vm.$set trigger
33
+ // update() so filters are applied.
34
+ // therefore we have to record cursor position
35
+ // so that after vm.$set changes the input
36
+ // value we can put the cursor back at where it is
37
+ var cursorPos
38
+ try {
39
+ cursorPos = el . selectionStart
40
+ } catch ( e ) { }
41
+ self . vm . $set ( self . key , el [ attr ] )
42
+ if ( cursorPos !== undefined ) {
43
+ el . setSelectionRange ( cursorPos , cursorPos )
44
+ }
45
+ }
46
+ : function ( ) {
47
+ // no filters, don't let it trigger update()
48
+ self . lock = true
49
+ self . vm . $set ( self . key , el [ attr ] )
50
+ self . lock = false
51
+ }
32
52
el . addEventListener ( self . event , self . set )
33
53
34
54
// fix shit for IE9
@@ -51,6 +71,7 @@ module.exports = {
51
71
} ,
52
72
53
73
update : function ( value ) {
74
+ if ( this . lock ) return
54
75
/* jshint eqeqeq: false */
55
76
var self = this ,
56
77
el = self . el
You can’t perform that action at this time.
0 commit comments