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 = {
2626 : 'value'
2727
2828 // 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+ }
3252 el . addEventListener ( self . event , self . set )
3353
3454 // fix shit for IE9
@@ -51,6 +71,7 @@ module.exports = {
5171 } ,
5272
5373 update : function ( value ) {
74+ if ( this . lock ) return
5475 /* jshint eqeqeq: false */
5576 var self = this ,
5677 el = self . el
You can’t perform that action at this time.
0 commit comments