The manakai project

Web::DOM::Element

DOM Element object

DESCRIPTION

The Web::DOM::Element class implements the DOM Element interface. It represents an element in the document.

METHODS

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

$map = $el->attributes

Return the Web::DOM::NamedNodeMap object containing the content attributes for the element. [DOM]

$tokens = $el->class_list

Return the Web::DOM::TokenList object for the class attribute. [DOM]

$string = $el->class_name
$el->class_name ($string)
$el->class_list ($string)

Return or set the class attribute. [DOM]

$bool = $el->manakai_element_type_match ($nsurl, $local_name)

Return whether the namespace URL and local name are equal to the specified values or not. [MANAKAI]

$value = $el->get_attribute ($name)

Return the value of the specified attribute. If there is no attribute with the specified name, undef is returned. [DOM]

$arrayref = $el->get_attribute_names

Return a reference to a new array of the attribute names currently specified for the element. [DOM]

$value = $el->get_attribute_ns ($nsurl, $local_name)

Return the value of the attribute with the specified namespace URL and local name. If there is no attribute with the specified name, undef is returned. [DOM]

$attr = $el->get_attribute_node ($name)

Return the Web::DOM::Attr object for the specified attribute. If there is no attribute with the specified name, undef is returned. [DOM]

$indexed = $el->manakai_get_attribute_indexed_string_ns ($nsurl, $local_name)

Return the IndexedString <https://wiki.suikawiki.org/n/manakai%20index%20data%20structures#anchor-1> representation of the attribute with the specified namespace URL and local name. If there is no attribute with the specified name, undef is returned. [MANAKAIINDEX]

$attr = $el->get_attribute_node_ns ($nsurl, $local_name)

Return the Web::DOM::Attr object for the attribute with the specified namespace URL and local name. If there is no attribute with the specified name, undef is returned. [DOM]

$bool = $el->has_attribute ($name)

Return whether there is the specified attribute or not. [DOM]

$bool = $el->has_attribute_ns ($nsurl, $local_name)

Return whether there is the attribute with the specified namespace URL and local name or not. [DOM]

$bool = $el->has_attributes

Return whether the element has any content attribute or not. [DOM]

$string = $el->id
$el->id ($string)

Return or set the id attribute. [DOM]

$arrayref = $el->manakai_ids

Return the array reference containing the ID of the element, if any, or the empty array reference, otherwise. [MANAKAI]

$el->insert_adjacent_html ($position, $markup)

Parse the specified string and insert somewhere near the element. The first argument must be one of followings: beforebegin (before the start tag of the element), afterbegin (after the start tag of the element), beforeend (before the end tag of the element), or afterend (after the end tag of the element). The markup must be a character string in HTML or XML, depending on the type of the document. [DOMPARSING]

If the document is an XML document and the given string is not well-formed, the method throws an exception.

However, even if the document is an XML document and the node can't be serialized into the well-formed XML fragment, the method does not throw and does return an ill-formed XML fragment instead. This is a willful violation to the HTML Living Standard, to match current browsers' behavior. Future version of the module might throw an exception if browsers start to throw an exception.

See also "DEPENDENCY" in Web::DOM.

$name = $el->local_name
$name = $el->manakai_local_name [DEPRECATED]

Return the local name of the element. [DOM] [MANAKAI]

$url = $el->namespace_uri

Return the namespace URL of the element. If the element does not belong to any namespace, undef is returned. [DOM]

$string = $el->outer_html
$el->outer_html ($string)

Replace the element by the specified fragment of the markup. The markup must be a character string in HTML or XML, depending on the type of the document. [DOMPARSING]

If the document is an XML document and the given string is not well-formed, the method throws an exception.

However, even if the document is an XML document and the node can't be serialized into the well-formed XML fragment, the method does not throw and does return an ill-formed XML fragment instead. This is a willful violation to the HTML Living Standard, to match current browsers' behavior. Future version of the module might throw an exception if browsers start to throw an exception.

See also "DEPENDENCY" in Web::DOM.

$prefix = $el->prefix
$el->prefix ($prefix)

If no argument is specified, return the namespace prefix of the element, if any, or undef. [DOM]

If the argument is specified, the value is set as the namespace prefix of the element. If the value is undef, the namespace prefix is removed. [DOMNODEEXODUS] [MANAKAI]

$el->remove_attribute ($name)

Remove the attribute with the specified name. If no attribute is found, the method does nothing. [DOM]

$el->remove_attribute_ns ($nsurl, $local_name)

Remove the attribute with the specified namespace URL and local name. If no attribute is found, the method does nothing. [DOM]

$attr = $el->remove_attribute_node ($attr)

Remove the specified attribute from the element. The removed attribute is returned. [DOM]

$el->set_attribute ($name => $value)

Set the attribute with the specified name and value. If there is already the attribute with the same name, its value is replaced by the new one. [DOM]

$el->set_attribute_ns ($nsurl, $qname => $value)
$el->set_attribute_ns ($nsurl, [$prefix, $local_name] => $value)

Set the attribute with the specified namespace URL, qualified name, and value. If there is already the attribute with the same namespace URL / local name pair, its value is replaced by the new one. [DOM]

The qualified name can be represented as an array reference, where the first item is the prefix (or undef for the null namespace) and the second item is the local name. [DOMPERL]

$el->manakai_set_attribute_indexed_string_ns ($nsurl, $qname => $value)
$el->manakai_set_attribute_indexed_string_ns ($nsurl, [$prefix, $local_name] => $value)

Set the attribute with the specified namespace URL, qualified name, and value represented as an IndexedString <https://wiki.suikawiki.org/n/manakai%20index%20data%20structures#anchor-1>. If there is already the attribute with the same namespace URL / local name pair, its value is replaced by the new one. [MANAKAIINDEX]

The qualified name can be represented as an array reference, where the first item is the prefix (or undef for the null namespace) and the second item is the local name. [DOMPERL]

$old_attr = $el->set_attribute_node ($new_attr)
$old_attr = $el->set_attribute_node_ns ($new_attr)

Append (or replace, if exists) the attribute node to the list of attributes for the element. If there is already the attribute with same namespace URL / local name pair, the attribute is removed from the list and is returned by the method. [DOM]

$name = $el->tag_name

Return the tag name of the element. [DOM]

$name = $el->manakai_tag_name

Return the tag name of the element. Even when the element is an HTML element in the HTML document, this method returns the "real" tag name, without case folding. [MANAKAI]

Any HTML element uses Web::DOM::HTMLElement, a subclass of this class. Most HTML elements have more specific subclasses. See Web::DOM::HTMLElement for details. Likewise, Atom elements use Web::DOM::AtomElement.

In addition, obsolete methods insert_adjacent_element, insert_adjacent_text, and manakai_base_uri are available. [DOM] [DOMDTDEF]

SPECIFICATIONS

DOM

DOM Standard <https://dom.spec.whatwg.org/#interface-element>.

DOMNODEEXODUS

DOM Living Standard, commented out <view-source:https://dom.spec.whatwg.org/>.

DOMPARSING

DOM Parsing and Serialization <https://domparsing.spec.whatwg.org/>.

HTML

HTML Standard <https://www.whatwg.org/specs/web-apps/current-work/#htmlelement>.

DOMDTDEF

DOM Document Type Definitions <https://suika.suikawiki.org/www/markup/xml/domdtdef/domdtdef>.

DOMPERL

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

MANAKAI

manakai DOM Extensions <https://suika.suikawiki.org/~wakaba/wiki/sw/n/manakai++DOM%20Extensions>.

MANAKAIINDEX

manakai index data structures <https://wiki.suikawiki.org/n/manakai%20index%20data%20structures>.

SEE ALSO

Web::DOM::Node, Web::DOM::Attr.

AUTHOR

Wakaba <wakaba@suikawiki.org>.

LICENSE

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

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