DOMTokenList

sealed external class DOMTokenList : ListLike<String> (source)

A set of space-separated tokens. Such a set is returned by Element.classList, HTMLLinkElement.relList, HTMLAnchorElement.relList, HTMLAreaElement.relList, HTMLIframeElement.sandbox, or HTMLOutputElement.htmlFor. It is indexed beginning with 0 as with JavaScript Array objects. DOMTokenList is always case-sensitive.

MDN Reference

Properties

Link copied to clipboard
abstract val length: Int
Link copied to clipboard

Returns the associated set as string.

Functions

Link copied to clipboard
fun add(vararg tokens: String)

Adds all arguments passed, except those already present.

Link copied to clipboard
fun contains(token: String): Boolean

Returns true if token is present, and false otherwise.

Link copied to clipboard
abstract fun entries(): JsIterator<JsTuple2<Int, String>>
Link copied to clipboard
abstract fun forEach(action: (item: String) -> Unit)
Link copied to clipboard
open operator fun get(index: Int): String
open operator fun get(key: Symbol.iterator): () -> JsIterator<String>
Link copied to clipboard
fun item(index: Int): String?

Returns the token with index index.

Link copied to clipboard
open inline operator fun iterator(): Iterator<String>
Link copied to clipboard
abstract fun keys(): JsIterator<Int>
Link copied to clipboard
fun remove(vararg tokens: String)

Removes arguments passed, if they are present.

Link copied to clipboard
fun replace(token: String, newToken: String): Boolean

Replaces token with newToken.

Link copied to clipboard
fun supports(token: String): Boolean

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

Link copied to clipboard
fun toggle(token: String, force: Boolean = definedExternally): 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()).

Link copied to clipboard
abstract fun values(): JsIterator<String>