Skip to content

Commit 398419f

Browse files
committed
remove composition event listeners in v-model unbind
1 parent 74e2f38 commit 398419f

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/directives/model.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ module.exports = {
2828
: 'innerHTML'
2929

3030
var compositionLock = false
31-
el.addEventListener('compositionstart', function () {
31+
this.cLock = function () {
3232
compositionLock = true
33-
})
34-
el.addEventListener('compositionend', function () {
33+
}
34+
this.cUnlock = function () {
3535
compositionLock = false
36-
})
36+
}
37+
el.addEventListener('compositionstart', this.cLock)
38+
el.addEventListener('compositionend', this.cUnlock)
3739

3840
// attach listener
3941
self.set = self.filters
@@ -114,10 +116,13 @@ module.exports = {
114116
},
115117

116118
unbind: function () {
117-
this.el.removeEventListener(this.event, this.set)
119+
var el = this.el
120+
el.removeEventListener(this.event, this.set)
121+
el.removeEventListener('compositionstart', this.cLock)
122+
el.removeEventListener('compositionend', this.cUnlock)
118123
if (isIE9) {
119-
this.el.removeEventListener('cut', this.onCut)
120-
this.el.removeEventListener('keyup', this.onDel)
124+
el.removeEventListener('cut', this.onCut)
125+
el.removeEventListener('keyup', this.onDel)
121126
}
122127
}
123128
}

0 commit comments

Comments
 (0)