Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/website/awaited-dom/DOMTokenList.md
1029 views

AwaitedDOM / DOMTokenList

The DOMTokenList interface represents 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.

Properties

.length
W3C {#length}

Is an integer representing the number of objects stored in the object.

Type: Promise<number>

.value
W3C {#value}

A stringifier property that returns the value of the list as a string.

Type: Promise<string>

Methods

.add*(...tokens)*
W3C {#add}

Adds the specified token(s) to the list.

Arguments:

  • tokens string. A string representing the token (or tokens) to add to the tokenList.

Returns: Promise<void>

.contains*(token)*
W3C {#contains}

Returns true if the list contains the given token, otherwise false.

Arguments:

  • token string. A string representing the token you want to check for the existance of in the list.

Returns: Promise<boolean>

.entries*()*
W3C {#entries}

Returns an iterator, allowing you to go through all key/value pairs contained in this object.

Returns: Promise<>

.forEach*()*
W3C {#forEach}

Executes a provided callback function once per DOMTokenList element.

Returns: Promise<>

.item*(index)*
W3C {#item}

Returns the item in the list by its index, or undefined if index is greater than or equal to the list's length.

Arguments:

  • index number. A string representing the index of the item you want to return.

Returns: Promise<string>

.keys*()*
W3C {#keys}

Returns an iterator, allowing you to go through all keys of the key/value pairs contained in this object.

Returns: Promise<>

.remove*(...tokens)*
W3C {#remove}

Removes the specified token(s) from the list.

Arguments:

  • tokens string. A string representing the token you want to remove from the list. If the string is not in the list, no error is thrown, and nothing happens.

Returns: Promise<void>

.replace*(token, newToken)*
W3C {#replace}

Replaces token with newToken.

Arguments:

  • token string. A string representing the token you want to replace.

  • newToken string. A string representing the token you want to replace oldToken with.

Returns: Promise<boolean>

.supports*(token)*
W3C {#supports}

Returns true if a given token is in the associated attribute's supported tokens.

Arguments:

  • token string. A string containing the token to query for.

Returns: Promise<boolean>

.toggle*(token, force?)*
W3C {#toggle}

Removes token from the list if it exists, or adds token to the list if it doesn't. Returns a boolean indicating whether token is in the list after the operation.

Arguments:

  • token string. A string representing the token you want to toggle.

  • force boolean. A boolean that, if included, turns the toggle into a one way-only operation. If set to false, then token will only be removed, but not added. If set to true, then token will only be added, but not removed.

Returns: Promise<boolean>

.values*()*
W3C {#values}

Returns an iterator, allowing you to go through all values of the key/value pairs contained in this object.

Returns: Promise<>