Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent dupe events on enabled ClickableComponents #4316

Merged
merged 1 commit into from
May 11, 2017

Conversation

mister-ben
Copy link
Contributor

Description

Prevent ClickableComponents re-adding event listeners each time enabled() is called
Fixes #4312

Specific Changes proposed

  • Keeps track of enabled state (this.enabled_)
  • enable() doesn't do anything if the component is enabled, so the event handlers are not re-added

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chome, Firefox, IE)
    • Unit Tests updated or fixed
  • Reviewed by Two Core Contributors

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Another option would've been to just always do this.off before calling this.on in enable().

@gkatsev
Copy link
Member

gkatsev commented May 11, 2017

I guess we should fix this in 5.x as well. @mister-ben would you be able to make a PR for that? I could do it otherwise.

@gkatsev gkatsev merged commit 03bab83 into videojs:master May 11, 2017
@mister-ben
Copy link
Contributor Author

It's causing some tests in MenuButton and TextTracksControls to fail on 5.x, will need to dig into why.

gkatsev pushed a commit that referenced this pull request May 15, 2017
Like #4316 for v6, this prevents multiple click handlers being added if an already enabled component is enabled. In the PR for six, ClickableComponent was tracking this.enabled_ but this is incompatible with v5 on a MenuButton which also changes the state of this.enabled_.
Removes event handlers in enable() before adding them.
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.

ClickableComponent enable and disable method register events multiple times
2 participants