The manakai project

Web::DOM::TokenList

DOM DOMTokenList object

DESCRIPTION

The Web::DOM::TokenList class implements the DOM DOMTokenList interface.

The DOMTokenList object is used by, e.g., the class_list method of the elements, the rel_list method of the HTML hyperlink elements, and HTML sandbox, dropzone, and headers attributes.

METHODS

Following methods are available:

push @$tokens, $token1, $token2, ...
$tokens->add ($token1, $token2, ...)

Append specified tokens to the list. [DOM] [DOMPERL]

$boolean = $tokens->contains ($token)

Return whether the list contains the specified token or not. [DOM]

$string = $tokens->[$index]
$string = $tokens->item ($index)

Return the token in the list, specified by its index. [DOM] [DOMPERL]

Use of the item method is discouraged as it doesn't support Perl-ish ways to access items, such as negative indexing, while $node_list->[-1] works as intended.

$number = @$tokens
$number = $tokens->length

Return the number of the tokens in the list. [DOM] [DOMPERL]

$tokens->remove ($token1, $token2, ...)

Remove the specified tokens from the list. [DOM]

$boolean = $tokens->replace ($token, $new_token)

Replace the token, if any, by a new token and return whether any token is replaced or not. [DOM]

$bool = $tokens->toggle ($token)
$bool = $tokens->toggle ($token, $bool)

Change whether the token appears in the list or not. If the second argument is specified, the status is set to match that value. Otherwise, the status is changed to not equal to the current status. The method returns the new status. [DOM]

$string = '' . $tokens
$string = $tokens->value

Return the serialized representation of the tokens, joined by the space character. [DOM] [DOMPERL]

$tokens->value ($string)

Replace the tokens in the list by the tokens specified as the space-separeted list. [DOM]

The object supports Perl standard operations for array references, e.g. pop @$tokens. [DOMPERL]

SPECIFICATIONS

DOM

DOM Standard <https://dom.spec.whatwg.org/>.

DOMPERL

manakai's DOM Perl Binding <https://wiki.suikawiki.org/n/manakai's%20DOM%20Perl%20Binding>.

SEE ALSO

Web::DOM::Element.

AUTHOR

Wakaba <wakaba@suikawiki.org>.

LICENSE

Copyright 2013-2018 Wakaba <wakaba@suikawiki.org>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.