Popper: Fix memory leak on route change (#7715) #9757
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #7715 by addressing the two following issues:
doDestroy
method of vue-popper was returning right away without actually destroying the popper due toshowPopper
being true.forceDestroy
parameter is added to handle this case. An alternative fix could be to setshowPopper
tofalse
inbeforeDestroy
before callingdoDestroy
, but the parameter approach was chosen as it can be reused.destroy
method of popper.js was being successfully called, which in turn called_removeEventListeners
. Thetarget
that this method was removing thescroll
event listener from was not the same element to which the listener was added (this is due togetScrollParent
not being able to find the correct element as some of the top level nodes had already been destroyed). This caused the event listener (bound tothis
) to leak, and consequently the whole associated DOM and VDOM tree. The fix is to replace the logic to find the target in_removeEventListeners
and use the stored target to remove the listener from.dev
branch.