Skip to content

Commit c355319

Browse files
fenduruyyx990803
authored andcommitted
fix: clean up target variables to avoid memory leaks (#6932)
fix #6931
1 parent 4ad9a56 commit c355319

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/core/instance/events.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function initEvents (vm: Component) {
1919
}
2020
}
2121

22-
let target: Component
22+
let target: any
2323

2424
function add (event, fn, once) {
2525
if (once) {
@@ -40,6 +40,7 @@ export function updateComponentListeners (
4040
) {
4141
target = vm
4242
updateListeners(listeners, oldListeners || {}, add, remove, vm)
43+
target = undefined
4344
}
4445

4546
export function eventsMixin (Vue: Class<Component>) {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function normalizeEvents (on) {
2626
}
2727
}
2828

29-
let target: HTMLElement
29+
let target: any
3030

3131
function createOnceHandler (handler, event, capture) {
3232
const _target = target // save current target element in closure
@@ -78,6 +78,7 @@ function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
7878
target = vnode.elm
7979
normalizeEvents(on)
8080
updateListeners(on, oldOn, add, remove, vnode.context)
81+
target = undefined
8182
}
8283

8384
export default {

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

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
4646
const oldOn = oldVnode.data.on || {}
4747
target = vnode.elm
4848
updateListeners(on, oldOn, add, remove, vnode.context)
49+
target = undefined
4950
}
5051

5152
export default {

0 commit comments

Comments
 (0)