Browse Source

fix: clean up target variables to avoid memory leaks (#6932)

fix #6931
dev
fenduru 7 years ago
committed by Evan You
parent
commit
c3553196b8
  1. 3
      src/core/instance/events.js
  2. 3
      src/platforms/web/runtime/modules/events.js
  3. 1
      src/platforms/weex/runtime/modules/events.js

3
src/core/instance/events.js

@ -19,7 +19,7 @@ export function initEvents (vm: Component) {
}
}
let target: Component
let target: any
function add (event, fn, once) {
if (once) {
@ -40,6 +40,7 @@ export function updateComponentListeners (
) {
target = vm
updateListeners(listeners, oldListeners || {}, add, remove, vm)
target = undefined
}
export function eventsMixin (Vue: Class<Component>) {

3
src/platforms/web/runtime/modules/events.js

@ -26,7 +26,7 @@ function normalizeEvents (on) {
}
}
let target: HTMLElement
let target: any
function createOnceHandler (handler, event, capture) {
const _target = target // save current target element in closure
@ -78,6 +78,7 @@ function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
target = vnode.elm
normalizeEvents(on)
updateListeners(on, oldOn, add, remove, vnode.context)
target = undefined
}
export default {

1
src/platforms/weex/runtime/modules/events.js

@ -46,6 +46,7 @@ function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
const oldOn = oldVnode.data.on || {}
target = vnode.elm
updateListeners(on, oldOn, add, remove, vnode.context)
target = undefined
}
export default {

Loading…
Cancel
Save