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

fix: Remove target availability event listener on dispose (#29) #35

Merged
merged 2 commits into from
Feb 24, 2022

Conversation

izkmdz
Copy link
Contributor

@izkmdz izkmdz commented Feb 9, 2022

Fix for issue #29.

This commit removes the "webkitplaybacktargetavailabilitychanged" event listener when the component is disposed. It also provides a test case demo in which the user can remove (dispose) the AirPlay component from the videoJS player.

src/js/components/AirPlayButton.js Outdated Show resolved Hide resolved
docs/demo/test-cases/remove-air-play-button.html Outdated Show resolved Hide resolved
docs/demo/test-cases/remove-air-play-button.html Outdated Show resolved Hide resolved
docs/demo/test-cases/remove-air-play-button.html Outdated Show resolved Hide resolved
@izkmdz izkmdz force-pushed the ismendoza/fix-dispose-listener branch 2 times, most recently from 52bb4e2 to d20dc68 Compare February 14, 2022 18:49
@coveralls
Copy link

coveralls commented Feb 14, 2022

Coverage Status

Coverage remained the same at 0.0% when pulling ea0880d on izkmdz:ismendoza/fix-dispose-listener into 63a3908 on silvermine:master.

@izkmdz izkmdz force-pushed the ismendoza/fix-dispose-listener branch from 9865dbb to 61bb196 Compare February 23, 2022 17:22
if (event.availability === 'available') {
self.show();
} else {
self.hide();
}
}

mediaEl.addEventListener('webkitplaybacktargetavailabilitychanged', onTargetAvailabilityChanged, this);
Copy link
Contributor

Choose a reason for hiding this comment

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

One other thing I missed in the previous review: The third parameter to the addEventListener method is either an options object or a boolean flag, not a reference to this: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener

We should just remove the third parameter here and below. The onTargetAvailabilityChanged handler has access to the proper this via the self variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. 👍 Thanks!

)

Fix for issue silvermine#29.

This commit removes the "webkitplaybacktargetavailabilitychanged"
event listener when the component is disposed. It also provides a
test case demo in which the user can remove (dispose) the AirPlay
component from the videoJS player.
@izkmdz izkmdz force-pushed the ismendoza/fix-dispose-listener branch from 61bb196 to ea0880d Compare February 24, 2022 00:27
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.

None yet

3 participants