src/utilities/dom-class-list/index.js
function toggleClass( element, className, forceFlag ) {
  let hasClass = false;
  if ( hasClassList ) {
    hasClass = element.classList.toggle( className );
  } else if ( forceFlag === false || contains( element, className ) ) {
    removeClass( element, forceFlag );
  } else {
    addClass( element, className );
    hasClass = true;
  }

  return hasClass;
}
function toggleClass( element, className, forceFlag ) {
  let hasClass = false;
  if ( hasClassList ) {
    hasClass = element.classList.toggle( className );
  } else if ( forceFlag === false || contains( element, className ) ) {
    removeClass( element, forceFlag );
  } else {
    addClass( element, className );
    hasClass = true;
  }

  return hasClass;
}
function toggleClass ( element , className , forceFlag ) { let hasClass = false ; if ( hasClassList ) { hasClass = element . classList . toggle ( className ) ; } else if ( forceFlag === false || contains ( element , className ) ) { removeClass ( element , forceFlag ) ; } else { addClass ( element , className ) ; hasClass = true ; } return hasClass ; }
Toggle CSS class on an element.

@param {HTMLNode} element - A DOM element.
@param {string} className - CSS selector.
@param {boolean} forceFlag - True if `className` class
should be forcibly removed.
@returns {boolean} True if the flag existed, false otherwise.
Toggle CSS class on an element .