addClass(element, className) {
    if (!element || !(element instanceof HTMLElement)) {
      return this;
    }
    // Allow templates to intercept.
    const classes = element.getAttribute('class');
    if (!classes?.includes(className)) {
      element.setAttribute('class', `${classes} ${className}`);
    }

    return this;
  }
Adds a class to a DOM element.
@param {HTMLElement} element - The element to add a class to.
@param {string} className - The name of the class to add.
@returns {this} - The instance of the element.