Class ElementClassManager<T>

A class to manage the applied classes on an HTML Element. The class keeps track of what classes were added and can use that to create differentials.

Type Parameters

  • T extends HTMLElement = HTMLElement

Constructors

Properties

Accessors

Methods

Constructors

Properties

element: T

Accessors

Methods

  • Update the applied classes to the given state. New classes will be applied, and classes not in the new state will be removed.

    Parameters

    Returns void

  • Toggle classes from the HTML Element.

    Parameters

    • classes: Record<string, boolean>

      The classes and their toggle state

    Returns {
        added: string[];
        removed: string[];
    }

    affectedClasses - lists of classes that were added / removed from the state

    • added: string[]
    • removed: string[]
  • Toggle classes from the HTML Element.

    Parameters

    • classes:
          | undefined
          | null
          | string
          | string[]

      The classes to remove

    • Optionalstate: boolean

      Force the state of classes

    Returns {
        added: string[];
        removed: string[];
    }

    affectedClasses - lists of classes that were added / removed from the state

    • added: string[]
    • removed: string[]