Skip to content

Commit

Permalink
fix(dom): in removeClass, check element for null in case of a dispose…
Browse files Browse the repository at this point in the history
…d player (videojs#6701)
  • Loading branch information
travisbader authored and edirub committed Jun 8, 2023
1 parent c3b7dfb commit 5c38a60
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/js/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ export function addClass(element, classToAdd) {
* The DOM element with class name removed.
*/
export function removeClass(element, classToRemove) {
// Protect in case the player gets disposed
if (!element) {
log.warn("removeClass was called with an element that doesn't exist");
return null;
}
if (element.classList) {
element.classList.remove(classToRemove);
} else {
Expand Down

0 comments on commit 5c38a60

Please sign in to comment.