The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

SPVM::Eg::Node::Document - Document in JavaScript

Description

The Eg::Node::Document class in SPVM represents any XML/HTML page which is the DOM tree. This class itself is an abstruct class.

This class is a port of Document in JavaScript.

Usage

  my $html_document = Eg->document->implementation->create_html_document("Title");
  
  my $xml_document = Eg->document->implementation->create_document(
    "http://www.w3.org/1999/xhtml",
    "html",
  );

Inheritance

Eg::Node

Fields

doctype

has doctype : ro protected Eg::Node::DocumentType;

The Document Type Declaration (DTD) associated with current document.

For details, see Document.doctype in JavaScript.

implementation

has implementation : ro Eg::DOM::Implementation;

An Eg::DOM::Implementation object associated with the current document.

For details, see Document.implementation in JavaScript.

Instance Methods

title

method title : string ();

Sets the current title of the document.

For details, see Document.title in JavaScript.

set_title

method set_title : string ($title : string);

Returns the current title of the document.

For details, see Document.title in JavaScript.

create_element

method create_element : Eg::Node::Element ($tag_name : string);

In an HTML document, this method creates the HTML element specified by $tag_name, or an Eg::Node::Element::HTML::Unknown if $tag_name isn't recognized.

For details, see Document.createElement in JavaScript.

create_text_node

method create_text_node : Eg::Node::Text ($node_value : string);

Creates and returns a new Text node.

For details, see Document.createTextNode in JavaScript.

create_comment

method create_comment : Eg::Node::Comment ($node_value : string);

Creates a new comment node, and returns it.

For details, see Document.createComment in JavaScript.

create_cdata_section

method create_cdata_section : Eg::Node::CDATASection ($node_value : string);

Creates a new CDATA section node, and returns it.

For details, see Document.createCDATASection in JavaScript.

create_document_fragment

method create_document_fragment : Eg::Node::DocumentFragment ();

Creates a new empty DocumentFragment into which DOM nodes can be added to build an offscreen DOM tree.

For details, see Document.createDocumentFragment in JavaScript.

create_attribute

method create_attribute : Eg::Node::Attr ($name : string);

Creates a new attribute node, and returns it.

For details, see Document.createAttribute in JavaScript.

create_attribute_ns

method create_attribute_ns : Eg::Node::Attr ($namespace_uri : string, $qualified_name : string);

Creates a new attribute node with the specified namespace URI and qualified name, and returns it.

For details, see Document.createAttributeNS in JavaScript.

create_processing_instruction

method create_processing_instruction : Eg::Node::ProcessingInstruction ($target : string, $data : string);

Generates a new processing instruction node and returns it.

For details, see Document.createProcessingInstruction in JavaScript.

document_element

method document_element : Eg::Node::Element ();

Returns the element that is the root element of the document (for example, the <html> element for HTML documents).

For details, see Document.documentElement in JavaScript.

method head : Eg::Node::Element ();

Returns the head element of the current document.

For details, see Document.head in JavaScript.

body

method body : Eg::Node::Element ();

Returns the <body> or <frameset> node of the current document, or undef if no such element exists.

For details, see Document.body in JavaScript.

Well Known Child Classes

Copyright & License

Copyright (c) 2024 Yuki Kimoto

MIT License