Interface DOMTokenList
@JsType(isNative=true,
namespace="<global>")
public interface DOMTokenList
A GWT wrapper for the native JavaScript
DOMTokenList interface.
This represents a set of space-separated tokens, primarily used for the
part property of an HTML element, allowing for manipulation of its
CSS classes.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given token to the list.booleanReturns a boolean value indicating whether the list contains the given token.intGets the number of tokens in the list.getValue()Gets the string representation of the token list.voidRemoves the given token from the list.booleanReplaces an existing token with a new token.booleanRemoves the given token from the list if it is present, and adds it if it is not.booleanTurns the toggle into a one way-only operation.
-
Method Details
-
add
Adds the given token to the list.If the token already exists in the list, it is not added again.
- Parameters:
token- The token to add to the list.
-
remove
Removes the given token from the list. If the token does not exist in the list, no action is taken.- Parameters:
token- The string token to remove from the list.
-
contains
Returns a boolean value indicating whether the list contains the given token.- Parameters:
token- The string token to check for.- Returns:
trueif the token is found, otherwisefalse.
-
toggle
Removes the given token from the list if it is present, and adds it if it is not.- Parameters:
token- The token to toggle.- Returns:
trueif the token is now present in the list, andfalseotherwise.
-
toggle
Turns the toggle into a one way-only operation. If the `force` parameter is true, this method adds the specified token if it's not already present. If `force` is false, it removes the token if it is present.- Parameters:
token- The token to toggle.force- If true, the token is added. If false, the token is removed.- Returns:
trueif the token is now present in the list, andfalseotherwise.
-
replace
Replaces an existing token with a new token.If the token to replace is not found in the list, this method does nothing and returns
false. If the token is found, it is replaced by the new token and the method returnstrue.- Parameters:
oldToken- The token to be replaced.newToken- The new token.- Returns:
trueif the replacement was successful,falseotherwise.
-
getLength
@JsProperty int getLength()Gets the number of tokens in the list.- Returns:
- the number of tokens.
-
getValue
Gets the string representation of the token list.- Returns:
- a space-separated string containing all the tokens in the list.
-