Skip to content

fix: v-scroll directive event listener leak#1365

Open
rocka wants to merge 1 commit intomuseui:masterfrom
rocka:master
Open

fix: v-scroll directive event listener leak#1365
rocka wants to merge 1 commit intomuseui:masterfrom
rocka:master

Conversation

@rocka
Copy link
Copy Markdown

@rocka rocka commented May 30, 2019

There's a heavy event listener leak when using v-scroll directive.

image

The performance profile was captured in https://muse-ui.org/#/zh-CN/directives . When the page scrolls, there's just tons of event listeners been attached, but none of them got removed.

https://github.com/museui/muse-ui/blob/master/src/internal/directives/scroll.js#L38

I think the update function in this directive was totally unnecessary, according to Vue Custom Directive Guide.

To demonstrate this, there's a fiddle: https://jsfiddle.net/zgrxt69h/ . update was removed, and it still works fine.

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #1365 into master will decrease coverage by 0.19%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #1365     +/-   ##
=========================================
- Coverage   30.18%   29.98%   -0.2%     
=========================================
  Files         220      220             
  Lines        3578     3578             
  Branches      749      749             
=========================================
- Hits         1080     1073      -7     
- Misses       1880     1885      +5     
- Partials      618      620      +2
Impacted Files Coverage Δ
src/internal/directives/scroll.js 81.25% <ø> (ø) ⬆️
src/utils/dom.js 0% <0%> (-13.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 74f78df...874031d. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants