platform/video.videojs/dist/video.es.js
function toggleClass(element, classToToggle, predicate) {

  // This CANNOT use `classList` internally because IE does not support the
  // second parameter to the `classList.toggle()` method! Which is fine because
  // `classList` will be used by the add/remove functions.
  var has = hasClass(element, classToToggle);

  if (typeof predicate === 'function') {
    predicate = predicate(element, classToToggle);
  }

  if (typeof predicate !== 'boolean') {
    predicate = !has;
  }

  // If the necessary class operation matches the current state of the
  // element, no action is required.
  if (predicate === has) {
    return;
  }

  if (predicate) {
    addClass(element, classToToggle);
  } else {
    removeClass(element, classToToggle);
  }

  return element;
}
function toggleClass(element, classToToggle, predicate) {

  // This CANNOT use `classList` internally because IE does not support the
  // second parameter to the `classList.toggle()` method! Which is fine because
  // `classList` will be used by the add/remove functions.
  var has = hasClass(element, classToToggle);

  if (typeof predicate === 'function') {
    predicate = predicate(element, classToToggle);
  }

  if (typeof predicate !== 'boolean') {
    predicate = !has;
  }

  // If the necessary class operation matches the current state of the
  // element, no action is required.
  if (predicate === has) {
    return;
  }

  if (predicate) {
    addClass(element, classToToggle);
  } else {
    removeClass(element, classToToggle);
  }

  return element;
}
The callback definition for toggleElClass.

@callback Dom~PredicateCallback
@param {Element} element
The DOM element of the Component.

@param {string} classToToggle
The `className` that wants to be toggled

@return {boolean|undefined}
- If true the `classToToggle` will get added to `element`.
- If false the `classToToggle` will get removed from `element`.
- If undefined this callback will be ignored
 
Adds or removes a CSS class name on an element depending on an optional
condition or the presence/absence of the class name.

@param {Element} element
The element to toggle a class name on.

@param {string} classToToggle
The class that should be toggled

@param {boolean|PredicateCallback} [predicate]
See the return value for {@link Dom~PredicateCallback}

@return {Element}
The element with a class that has been toggled.