The manakai project

Web::DOM::CharacterData

DOM CharacterData object

DESCRIPTION

The Web::DOM::CharacterData class implements the DOM CharacterData interface, which is inherited by Web::DOM::Text, Web::DOM::Comment, and Web::DOM::ProcessingInstruction.

METHODS

In addition to the methods of classes Web::DOM::EventTarget, Web::DOM::Node, and Web::DOM::ChildNode, following methods are available:

$node->append_data ($text)

Append the specified character string to the data of the node. [DOM]

$node->delete_data ($offset, $count)

Delete the substring of the data of the node, specified by offset and length. Offset and length are interpreted as numbers of UTF-16 code units. [DOM]

Use of this method is discouraged.

$text = $node->data
$node->data ($text)

Return or set the text data of the node. [DOM]

$node->insert_data ($offset, $data)

Insert a string at the specified location in the data of the node. Offset is interpreted as numbers of UTF-16 code units. [DOM]

Use of this method is discouraged.

$number = $node->length

Return the number of UTF-16 code units in the data of the node. [DOM]

Use of this method is discouraged in favor of length $node->data.

$node->replace_data ($offset, $count, $data)

Replace the substring of the data of the node, specified by offset and length by another string. Offset and length are interpreted as numbers of UTF-16 code units. [DOM]

Use of this method is discouraged.

$text = $node->substring_data ($offset, $count)

Return the substring of the data of the node, identified by the specified offset and length. Offset and length are interpreted as numbers of UTF-16 code units. [DOM]

Use of this method is discouraged in favor of substr $node->data, $offset, $count.

Most of methods are deprecated in favor of Perl's standard string operations. As DOM methods are defined in terms of UTF-16 code units while Perl strings are sequences of utf8 characters, and as Web IDL and Perl have different rules on interpretation of negative offset/count values, they exhibits inconsistent behaviors with Perl's standard string operations and they are not implemented in efficient ways. Moreover, these method can break surrogate pairs. HOW THEY INTERACT WITH CHARACTERS GREATER THAN U+FFFF IS SUBJECT TO CHANGE!

Any CharacterData object is an instance of one of its subclasses. For example, a CharacterData object whose node_type is TEXT_NODE is an instance of Web::DOM::Text. There are following subclasses:

Web::DOM::Text, Web::DOM::Comment, and Web::DOM::ProcessingInstruction.

SPECIFICATIONS

DOM

DOM Living Standard <http://dom.spec.whatwg.org/#interface-characterdata>.

DOMPERL

manakai's DOM Perl Binding <http://suika.suikawiki.org/~wakaba/wiki/sw/n/manakai%27s%20DOM%20Perl%20Binding>.

SEE ALSO

Web::DOM::Node.

AUTHOR

Wakaba <wakaba@suikawiki.org>.

LICENSE

Copyright 2012-2014 Wakaba <wakaba@suikawiki.org>.

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