Interface DOMTokenList

    interface DOMTokenList {
        length: number;
        value: string;
        [iterator](): ArrayIterator<string>;
        add(...tokens: string[]): void;
        contains(token: string): boolean;
        entries(): ArrayIterator<[number, string]>;
        forEach(callbackfn: ((value: string, key: number, parent: DOMTokenList) => void), thisArg?: any): void;
        item(index: number): string;
        keys(): ArrayIterator<number>;
        remove(...tokens: string[]): void;
        replace(token: string, newToken: string): boolean;
        supports(token: string): boolean;
        toggle(token: string, force?: boolean): boolean;
        toString(): string;
        values(): ArrayIterator<string>;
        [index: number]: string;
    }

    Indexable

    • [index: number]: string

    Properties

    length: number

    Returns the number of tokens.

    MDN Reference

    value: string

    Returns the associated set as string.

    Can be set, to change the associated attribute.

    MDN Reference

    Methods

    • Adds all arguments passed, except those already present.

      Throws a "SyntaxError" DOMException if one of the arguments is the empty string.

      Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.

      MDN Reference

      Parameters

      • Rest...tokens: string[]

      Returns void

    • Returns true if token is present, and false otherwise.

      MDN Reference

      Parameters

      • token: string

      Returns boolean

    • Parameters

      • callbackfn: ((value: string, key: number, parent: DOMTokenList) => void)
          • (value, key, parent): void
          • Parameters

            Returns void

      • OptionalthisArg: any

      Returns void

    • Returns the token with index index.

      MDN Reference

      Parameters

      • index: number

      Returns string

    • Removes arguments passed, if they are present.

      Throws a "SyntaxError" DOMException if one of the arguments is the empty string.

      Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.

      MDN Reference

      Parameters

      • Rest...tokens: string[]

      Returns void

    • Replaces token with newToken.

      Returns true if token was replaced with newToken, and false otherwise.

      Throws a "SyntaxError" DOMException if one of the arguments is the empty string.

      Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.

      MDN Reference

      Parameters

      • token: string
      • newToken: string

      Returns boolean

    • Returns true if token is in the associated attribute's supported tokens. Returns false otherwise.

      Throws a TypeError if the associated attribute has no supported tokens defined.

      MDN Reference

      Parameters

      • token: string

      Returns boolean

    • If force is not given, "toggles" token, removing it if it's present and adding it if it's not present. If force is true, adds token (same as add()). If force is false, removes token (same as remove()).

      Returns true if token is now present, and false otherwise.

      Throws a "SyntaxError" DOMException if token is empty.

      Throws an "InvalidCharacterError" DOMException if token contains any spaces.

      MDN Reference

      Parameters

      • token: string
      • Optionalforce: boolean

      Returns boolean

    • Returns string