DOMTokenList

js.html.DOMTokenList (extern class)

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.

Documentation DOMTokenList by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

Instance Members

length: Int

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


value: String

The value of the list as a DOMString.


item(index: Int): String

Returns an item in the list by its index (returns undefined if the number is greater than or equal to the length of the list).

Name Type
index Int
Returns
String

contains(token: String): Bool

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

Name Type
token String
Returns
Bool

add(tokens: haxe.extern.Rest): Void

Adds the given token to the list.

Name Type
tokens haxe.extern.Rest

remove(tokens: haxe.extern.Rest): Void

Removes the specified token from the list.

Name Type
tokens haxe.extern.Rest

replace(token: String, newToken: String): Bool

Replaces an existing token with a new token.

Name Type
token String
newToken String
Returns
Bool

toggle(token: String, ?force: Bool): Bool

Removes a given token from the list and returns false. If token doesn't exist it's added and the function returns true.

Name Type Default
token String
force Bool (optional)
Returns
Bool

supports(token: String): Bool

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

Name Type
token String
Returns
Bool