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
Methods
[iterator]
- "[iterator]"(): ArrayIterator<string>
Returns ArrayIterator<string>
add
- add(...tokens: string[]): void
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.
Parameters
- ...tokens: string[]
Returns void
contains
entries
- entries(): ArrayIterator<[number, string]>
Returns ArrayIterator<[number, string]>
forEach
- forEach(
callbackfn: (value: string, key: number, parent: DOMTokenList) => void,
thisArg?: any,
): void Parameters
- callbackfn: (value: string, key: number, parent: DOMTokenList) => void
Optional
thisArg: any
Returns void
item
keys
- keys(): ArrayIterator<number>
Returns ArrayIterator<number>
remove
- remove(...tokens: string[]): void
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.
Parameters
- ...tokens: string[]
Returns void
replace
- replace(token: string, newToken: string): boolean
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.
Parameters
- token: string
- newToken: string
Returns boolean
supports
toggle
- toggle(token: string, force?: boolean): 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.
Parameters
- token: string
Optional
force: boolean
Returns boolean
toString
values
- values(): ArrayIterator<string>
Returns ArrayIterator<string>
Returns the number of tokens.
MDN Reference