Unicorn ECMAScript Interpreter
DOM Extensions
Reference Manual
Version 2.0 (Draft)
31 October 2024

Abstract

This document describes DOM extensions supported by Unicorn ECMAScript Interpreter (UESI).

Status of this document

This document forms part of the Unicorn ECMAScript Interpreter (UESI) Reference Manual.

Comments on this document may be sent to [email protected]

Table of contents

Appendices


1 Introduction

This document describes DOM extensions supported by Unicorn ECMAScript Interpreter (UESI).

2 Overview

DOM extensions provide built-in ECMAScript objects that implement ECMAScript bindings for interfaces defined in DOM Level 1.

Node objects implement bindings for Node interface specified by DOM.

NodeList objects implement bindings for NodeList interface specified by DOM.

NamedNodeMap objects implement bindings for NamedNodeMap interface specified by DOM.

DOMImplementation objects implement bindings for DOMImplementation interface specified by DOM.

DocumentFragment objects implement bindings for DocumentFragment interface specified by DOM.

Document objects implement bindings for Document interface specified by DOM.

CharacterData objects implement bindings for CharacterData interface specified by DOM.

Attr objects implement bindings for Attr interface specified by DOM.

Element objects implement bindings for Element interface specified by DOM.

Text objects implement bindings for Text interface specified by DOM.

Comment objects implement bindings for Comment interface specified by DOM.

CDATASection objects implement bindings for CDATASection interface specified by DOM.

EntityReference objects implement bindings for EntityReference interface specified by DOM.

ProcessingInstruction objects implement bindings for ProcessingInstruction interface specified by DOM.

Reader objects are designed to traverse the DOM subtree in the document order, generating the appropriate stream of SAX2 events. Reader objects implement XML Stream interface and can be used in any context where XML Stream is required. Reader objects do not implement any specific DOM interface.

Writer objects are designed process the stream of SAX2 events, creating a set of DOM nodes and appending these nodes to the children list of a given root node. Writer objects implement XML ContentHandler interface and can be used in any context where XML ContentHandler is required. Writer objects do not implement any specific DOM interface.

3 Conventions

Concepts and notation of the ECMA-262 Standard (ECMAScript Language Specification) are used in this document.

This document contains no detailed description for the semantics of DOM-based objects, their properties and functions. Refer the original DOM specification for details.

This document relies also on the concepts introduced in "Unicorn ECMAScript Interpreter Reference Manual. XML Extensions".

4 DOM Objects

There are certain built-in DOM extension objects available whenever UESI begins execution of a program. One, the DOM object, is accessible as an initial property of the global object. Others are accessible as initial properties of the DOM object.

All DOM extension objects implement the semantics of native ECMAScript objects as specified in ECMA-262.

In every case, the length property of a built-in Function object described in this section has the attributes { DontEnum, DontDelete, ReadOnly } (and no others). Every other property described in this section has the attributes { DontEnum, DontDelete } (and no others) unless otherwise specified.

4.1 Semantics of DOM Objects

DOM extension objects which implement bindings for interfaces specified by DOM, have semantics of native objects as defined by ECMAScript. Every DOM extension object implementing binding for any particular DOM interface is linked to the intrinsic object which implements that interface and is handled by the underlying DOM implementation. The value of internal [[Value]] property of the DOM extension object contains reference to the corresponding intrinsic object.

It is assumed, that intrinsic objects handled by the underlying DOM implementation are independent from ECMAScript objects. In particular, several ECMAScript objects may reference the same intrinsic DOM object. For instance, for the given intrinsic object that implements Element interface, two ECMAScript objects may exist, one having [[Class]] equal to "DOM.Node", another having [[Class]] equal to "DOM.Element", and both having [[Value]] containing the reference to that instrinsic object.

4.1.1 Type Conversion

As the specification mechanism, several type converion functions are defined. All of them accept an ECMAScript value as their single argument and return an ECMAScript value as the result of conversion.

Note that every conversion function specified here may return null value. However, if null is not allowed in the context, where this conversion function was invoked, the runtime error is generated.

4.1.1.1 ToDOMString(value)

If value is null, return null. Otherwise, return ToString( value ).

4.1.1.2 ToNode(value)

If value is null, return null. If value is the Node object (its [[Class]] is "DOM.Node"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements Node interface, create and return a new Node instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.1.1.3 ToNodeList(value)

If value is null, return null. If value is the NodeList object (its [[Class]] is "DOM.NodeList"), return value unchanged. In all other cases generate a runtime error.

4.1.1.4 ToNamedNodeMap(value)

If value is null, return null. If value is the NamedNodeMap object (its [[Class]] is "DOM.NamedNodeMap"), return value unchanged. In all other cases generate a runtime error.

4.1.1.5 ToDOMImplemantation(value)

If value is null, return null. If value is the DOMImplementation object (its [[Class]] is "DOM.DOMImplementation"), return value unchanged. In all other cases generate a runtime error.

4.1.1.6 ToDocumentFragment(value)

If value is null, return null. If value is the DocumentFragment object (its [[Class]] is "DOM.DocumentFragment"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements DocumentFragment interface, create and return a new DocumentFragment instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.1.1.7 ToDocument(value)

If value is null, return null. If value is the Document object (its [[Class]] is "DOM.Document"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements Document interface, create and return a new Document instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.1.1.8 ToCharacterData(value)

If value is null, return null. If value is the CharacterData object (its [[Class]] is "DOM.CharacterData"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements CharacterData interface, create and return a new CharacterData instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.1.1.9 ToAttr(value)

If value is null, return null. If value is the Attr object (its [[Class]] is "DOM.Attr"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements Attr interface, create and return a new Attr instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.1.1.10 ToElement(value)

If value is null, return null. If value is the Element object (its [[Class]] is "DOM.Element"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements Element interface, create and return a new Element instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.1.1.11 ToText(value)

If value is null, return null. If value is the Text object (its [[Class]] is "DOM.Text"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements Text interface, create and return a new Text instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.1.1.12 ToComment(value)

If value is null, return null. If value is the Comment object (its [[Class]] is "DOM.Comment"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements Comment interface, create and return a new Comment instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.1.1.13 ToCDATASection(value)

If value is null, return null. If value is the CDATASection object (its [[Class]] is "DOM.CDATASection"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements CDATASection interface, create and return a new CDATASection instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.1.1.14 ToEntityReference(value)

If value is null, return null. If value is the EntityReference object (its [[Class]] is "DOM.EntityReference"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements EntityReference interface, create and return a new EntityReference instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.1.1.15 ToProcessingInstruction(value)

If value is null, return null. If value is the ProcessingInstruction object (its [[Class]] is "DOM.ProcessingInstruction"), return value unchanged. Otherwise, if value is an object having the internal [[Value]] property referencing the intrinsic DOM object that implements ProcessingInstruction interface, create and return a new ProcessingInstruction instance that has [[Value]] property referencing the same intrinsic object. In all other cases generate a runtime error.

4.2 The DOM Object

The DOM object does not have a [[Construct]] property; it is not possible to use the DOM object as a constructor with the new operator.

The DOM object does not have a [[Call]] property; it is not possible to invoke the DOM object as a function.

The value of the internal [[Prototype]] property of the DOM object is the Object prototype. The value of the internal [[Class]] property of the DOM object is "DOM".

4.2.1 Constructor Properties of the DOM Object

4.3 Node Objects

Node objects implement bindings for Node interface specified by DOM.

4.3.1 The Node Constructor Called as a Function

When DOM.Node is called as a function rather than a constructor, it performs a type conversion.

4.3.1.1 DOM.Node(value)

Returns an object value computed by ToNode( value ).

4.3.2 The Node Constructor

When DOM.Node is called as part of a new expression, it performs a type conversion rather than creation of a new object.

4.3.2.1 new DOM.Node(value)

Returns an object value computed by ToNode( value ).

4.3.3 Properties of the Node Constructor

The value of the internal [[Prototype]] property of the Node constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 1), the Node constructor has the following properties.

4.3.3.1 DOM.Node.prototype

The initial value of the DOM.Node.prototype is the Node prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.2 DOM.Node.ELEMENT_NODE

The number value of 1 which corresponds to the constant ELEMENT_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.3 DOM.Node.ATTRIBUTE_NODE

The number value of 2 which corresponds to the constant ATTRIBUTE_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.4 DOM.Node.TEXT_NODE

The number value of 3 which corresponds to the constant TEXT_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.5 DOM.Node.CDATA_SECTION_NODE

The number value of 4 which corresponds to the constant CDATA_SECTION_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.6 DOM.Node.ENTITY_REFERENCE_NODE

The number value of 5 which corresponds to the constant ENTITY_REFERENCE_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.7 DOM.Node.ENTITY_NODE

The number value of 6 which corresponds to the constant ENTITY_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.8 DOM.Node.PROCESSING_INSTRUCTION_NODE

The number value of 7 which corresponds to the constant PROCESSING_INSTRUCTION_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.9 DOM.Node.COMMENT_NODE

The number value of 8 which corresponds to the constant COMMENT_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.10 DOM.Node.DOCUMENT_NODE

The number value of 9 which corresponds to the constant DOCUMENT_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.11 DOM.Node.DOCUMENT_TYPE_NODE

The number value of 10 which corresponds to the constant DOCUMENT_TYPE_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.12 DOM.Node.DOCUMENT_FRAGMENT_NODE

The number value of 11 which corresponds to the constant DOCUMENT_FRAGMENT_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.3.13 DOM.Node.NOTATION_NODE

The number value of 12 which corresponds to the constant NOTATION_NODE of the Node interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.3.4 Properties of the Node Prototype Object

The value of the internal [[Prototype]] property of the Node prototype object is the Object prototype. The value of the internal [[Class]] property of the Node prototype object is "Object".

In the following descriptions of functions that are properties of the Node prototype object, the phrase "this Node object" refers to the object that is the result of applying ToNode to the this value for the invocation of the function.

4.3.4.1 DOM.Node.prototype.constructor

The initial value of DOM.Node.prototype.constructor is the built-in Node constructor.

4.3.4.2 DOM.Node.prototype.insertBefore(newChild, refChild)

Inserts the node newChild into the list of children of this Node object before the existing node refChild. Corresponds to the operation insertBefore of the Node interface specified by DOM.

4.3.4.3 DOM.Node.prototype.replaceChild(newChild, oldChild)

Replaces the child node oldChild with newChild in the list of children of this Node object, and returns the oldChild node. Corresponds to the operation replaceChild of the Node interface specified by DOM.

4.3.4.4 DOM.Node.prototype.removeChild(oldChild)

Removes the child node oldChild from the list of children of this Node object, and returns it. Corresponds to the operation removeChild of the Node interface specified by DOM.

4.3.4.5 DOM.Node.prototype.appendChild(newChild)

Adds the node newChild to the end or the list of children of this Node object. Corresponds to the operation appendChild of the Node interface specified by DOM.

4.3.4.6 DOM.Node.prototype.hasChildNodes()

Returns true if this Node object has any children, and false otherwise. Corresponds to the operation hasChildNodes of the Node interface specified by DOM.

4.3.4.7 DOM.Node.prototype.cloneNode(deep)

Returns a duplicate of this Node object. Corresponds to the operation cloneNode of the Node interface specified by DOM.

4.3.5 Properties of the Node Instances

The value of the internal [[Prototype]] property of the Node instance is the Node prototype object.

The value of the internal [[Class]] property of the Node instance is "DOM.Node".

The value of the internal [[Value]] property of the Node instance is the intrinsic object which implements Node interface specified by DOM.

Node instances inherit properties from their [[Prototype]] object and also have the following properties.

4.3.5.1 nodeName

The name of this node. Corresponds to the nodeName attribute of the Node interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.3.5.2 nodeValue

The value of this node. Corresponds to the nodeValue attribute of the Node interface specified by DOM.

4.3.5.3 nodeType

The type of this node. Corresponds to the nodeType attribute of the Node interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.3.5.4 parentNode

The parent of this node. Corresponds to the parentNode attribute of the Node interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.3.5.5 childNodes

The NodeList that contains all children of this node. Corresponds to the childNode attribute of the Node interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.3.5.6 firstChild

The first child of this node. Corresponds to the firstChild attribute of the Node interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.3.5.7 lastChild

The last child of this node. Corresponds to the lastChild attribute of the Node interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.3.5.8 previousSibling

The node immediately preceeding this node. Corresponds to the previousSibling attribute of the Node interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.3.5.9 nextSibling

The node immediately following this node. Corresponds to the nextSibling attribute of the Node interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.3.5.10 attributes

A NamedNodeMap containing the attributes of this node. Corresponds to the attributes attribute of the Node interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.3.5.11 ownerDocument

The Document object associated with this node. Corresponds to the ownerDocument attribute of the Node interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.4 NodeList Objects

NodeList objects implement bindings for NodeList interface specified by DOM.

4.4.1 The NodeList Constructor Called as a Function

When DOM.NodeList is called as a function rather than a constructor, it performs a type conversion.

4.4.1.1 DOM.NodeList(value)

Returns an object value computed by ToNodeList( value ).

4.4.2 The NodeList Constructor

When DOM.NodeList is called as part of a new expression, it performs a type conversion rather than creation of a new object.

4.4.2.1 new DOM.NodeList(value)

Returns an object value computed by ToNodeList( value ).

4.4.3 Properties of the NodeList Constructor

The value of the internal [[Prototype]] property of the NodeList constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 1), the NodeList constructor has the following properties.

4.4.3.1 DOM.NodeList.prototype

The initial value of the DOM.NodeList.prototype is the NodeList prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.4.4 Properties of the NodeList Prototype Object

The value of the internal [[Prototype]] property of the NodeList prototype object is the Object prototype. The value of the internal [[Class]] property of the NodeList prototype object is "Object".

In the following descriptions of functions that are properties of the NodeList prototype object, the phrase "this NodeList object" refers to the object that is the result of applying ToNodeList to the this value for the invocation of the function.

4.4.4.1 DOM.NodeList.prototype.constructor

The initial value of DOM.NodeList.prototype.constructor is the built-in NodeList constructor.

4.4.4.2 DOM.NodeList.prototype.item(index)

Returns the item in this NodeList object having the index index. Corresponds to the operation item of the NodeList interface specified by DOM.

4.4.5 Properties of the NodeList Instances

The value of the internal [[Prototype]] property of the NodeList instance is the NodeList prototype object.

The value of the internal [[Class]] property of the NodeList instance is "DOM.NodeList".

The value of the internal [[Value]] property of the NodeList instance is the intrinsic object which implements NodeList interface specified by DOM.

NodeList instances inherit properties from their [[Prototype]] object and also have the following properties.

4.4.5.1 length

The number of nodes in this NodeList. Corresponds to the length attribute of the NodeList interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.5 NamedNodeMap Objects

NamedNodeMap objects implement bindings for NamedNodeMap interface specified by DOM.

4.5.1 The NamedNodeMap Constructor Called as a Function

When DOM.NamedNodeMap is called as a function rather than a constructor, it performs a type conversion.

4.5.1.1 DOM.NamedNodeMap(value)

Returns an object value computed by ToNamedNodeMap( value ).

4.5.2 The NamedNodeMap Constructor

When DOM.NamedNodeMap is called as part of a new expression, it performs a type conversion rather than creation of a new object.

4.5.2.1 new DOM.NamedNodeMap(value)

Returns an object value computed by ToNamedNodeMap( value ).

4.5.3 Properties of the NamedNodeMap Constructor

The value of the internal [[Prototype]] property of the NamedNodeMap constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 1), the NamedNodeMap constructor has the following properties.

4.5.3.1 DOM.NamedNodeMap.prototype

The initial value of the DOM.NamedNodeMap.prototype is the NamedNodeMap prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.5.4 Properties of the NamedNodeMap Prototype Object

The value of the internal [[Prototype]] property of the NamedNodeMap prototype object is the Object prototype. The value of the internal [[Class]] property of the NamedNodeMap prototype object is "Object".

In the following descriptions of functions that are properties of the NamedNodeMap prototype object, the phrase "this NamedNodeMap object" refers to the object that is the result of applying ToNamedNodeMap to the this value for the invocation of the function.

4.5.4.1 DOM.NamedNodeMap.prototype.constructor

The initial value of DOM.NamedNodeMap.prototype.constructor is the built-in NamedNodeMap constructor.

4.5.4.2 DOM.NamedNodeMap.prototype.getNamedItem(name)

Retrieves a node specified by name from this NamedNodeMap object. Corresponds to the operation getNamedItem of the NamedNodeMap interface specified by DOM.

4.5.4.3 DOM.NamedNodeMap.prototype.setNamedItem(arg)

Adds a node to this NamedNodeMap object. Corresponds to the operation setNamedItem of the NamedNodeMap interface specified by DOM.

4.5.4.4 DOM.NamedNodeMap.prototype.removeNamedItem(name)

Removes a node specified by name from this NamedNodeMap object. Corresponds to the operation removeNamedItem of the NamedNodeMap interface specified by DOM.

4.5.4.5 DOM.NamedNodeMap.prototype.item(index)

Returns the item in this NamedNodeMap object having the index index. Corresponds to the operation item of the NamedNodeMap interface specified by DOM.

4.5.5 Properties of the NamedNodeMap Instances

The value of the internal [[Prototype]] property of the NamedNodeMap instance is the NamedNodeMap prototype object.

The value of the internal [[Class]] property of the NamedNodeMap instance is "DOM.NamedNodeMap".

The value of the internal [[Value]] property of the NamedNodeMap instance is the intrinsic object which implements NamedNodeMap interface specified by DOM.

NamedNodeMap instances inherit properties from their [[Prototype]] object and also have the following properties.

4.5.5.1 length

The number of nodes in this NamedNodeMap. Corresponds to the length attribute of the NamedNodeMap interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.6 DOMImplementation Objects

DOMImplementation objects implement bindings for DOMImplementation interface specified by DOM.

4.6.1 The DOMImplementation Constructor Called as a Function

When DOM.DOMImplemantation is called as a function rather than a constructor, it performs a type conversion.

4.6.1.1 DOM.DOMImplementation(value)

Returns an object value computed by ToDOMImplementation( value ).

4.6.2 The DOMImplementation Constructor

When DOM.DOMImplementation is called as part of a new expression, it performs a type conversion rather than creation of a new object.

4.6.2.1 new DOM.DOMImplementation(value)

Returns an object value computed by ToDOMImplementation( value ).

4.6.3 Properties of the DOMImplementation Constructor

The value of the internal [[Prototype]] property of the DOMImplementation constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 1), the DOMImplementation constructor has the following properties.

4.6.3.1 DOM.DOMImplementation.prototype

The initial value of the DOM.DOMImplementation.prototype is the DOMImplementation prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.6.4 Properties of the DOMImplementation Prototype Object

The value of the internal [[Prototype]] property of the DOMImplementation prototype object is the Object prototype. The value of the internal [[Class]] property of the DOMImplementation prototype object is "Object".

In the following descriptions of functions that are properties of the DOMImplementation prototype object, the phrase "this DOMImplementation object" refers to the object that is the result of applying ToDOMImplementation to the this value for the invocation of the function.

4.6.4.1 DOM.DOMImplementation.prototype.constructor

The initial value of DOM.DOMImplementation.prototype.constructor is the built-in DOMImplementation constructor.

4.6.4.2 DOM.DOMImplementation.prototype.hasFeature(feature, version)

Tests if a DOM implementation implements a specific feature. Corresponds to the operation hasFeature of the DOMImplementation interface specified by DOM.

4.6.5 Properties of the DOMImplementation Instances

The value of the internal [[Prototype]] property of the DOMImplementation instance is the DOMImplementation prototype object.

The value of the internal [[Class]] property of the DOMImplementation instance is "DOM.DOMImplementation".

The value of the internal [[Value]] property of the DOMImplementation instance is the intrinsic object which implements DOMImplementation interface specified by DOM.

DOMImplementation instances inherit properties from their [[Prototype]] object.

4.7 DocumentFragment Objects

DocumentFragment objects implement bindings for DocumentFragment interface specified by DOM.

4.7.1 The DocumentFragment Constructor Called as a Function

When DOM.DocumentFragment is called as a function rather than a constructor, it performs a type conversion.

4.7.1.1 DOM.DocumentFragment(value)

Returns an object value computed by ToDocumentFragment( value ).

4.7.2 The DocumentFragment Constructor

When DOM.DocumentFragment is called as part of a new expression, it either creates a new object or performs a type conversion depending on the argument value.

4.7.2.1 new DOM.DocumentFragment(value)

It value is an object whose [[Class]] property is "DOM.Document", a new DocumentFragment instance is constructed and returned. Otherwise, an object value computed by ToDocumentFragment( value ) is returned.

When the new DocumentFragment object is constructed, its [[Value]] property is set as follows.

Let D be an intrinsic object referenced by [[Value]] property of the value object. The operation createDocumentFragment of the Document interface specified by DOM is applied to D. Let F be an intrinsic object returned as the operation result. The [[Value]] property of the newly constructed object is set to F.

4.7.3 Properties of the DocumentFragment Constructor

The value of the internal [[Prototype]] property of the DocumentFragment constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 1), the DocumentFragment constructor has the following properties.

4.7.3.1 DOM.DocumentFragment.prototype

The initial value of the DOM.DocumentFragment.prototype is the DocumentFragment prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.7.4 Properties of the DocumentFragment Prototype Object

The value of the internal [[Prototype]] property of the DocumentFragment prototype object is the Node prototype object. The value of the internal [[Class]] property of the DocumentFragment prototype object is "Object".

4.7.4.1 DOM.DocumentFragment.prototype.constructor

The initial value of DOM.DocumentFragment.prototype.constructor is the built-in DocumentFragment constructor.

4.7.5 Properties of the DocumentFragment Instances

The value of the internal [[Prototype]] property of the DocumentFragment instance is the DocumentFragment prototype object.

The value of the internal [[Class]] property of the DocumentFragment instance is "DOM.DocumentFragment".

The value of the internal [[Value]] property of the DocumentFragment instance is the intrinsic object which implements DocumentFragment interface specified by DOM.

DocumentFragment instances inherit properties from their [[Prototype]] object and also have all properties specified for Node instances.

4.8 Document Objects

Document objects implement bindings for Document interface specified by DOM.

4.8.1 The Document Constructor Called as a Function

When DOM.Document is called as a function rather than a constructor, it performs a type conversion.

4.8.1.1 DOM.Document(value)

Returns an object value computed by ToDocument( value ).

4.8.2 The Document Constructor

When DOM.Document is called as part of a new expression, it is a constructor: it initializes and returns the newly created object.

4.8.2.1 new DOM.Document()

When the new Document instance is constructed, the intrinsic object that implements the Document interface specified by DOM is created. Reference to this object is assigned to the [[Value]] property of the newly constructed Document instance.

4.8.3 Properties of the Document Constructor

The value of the internal [[Prototype]] property of the Document constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 1), the Document constructor has the following properties.

4.8.3.1 DOM.Document.prototype

The initial value of the DOM.Document.prototype is the Document prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.8.4 Properties of the Document Prototype Object

The value of the internal [[Prototype]] property of the Document prototype object is the Node prototype object. The value of the internal [[Class]] property of the Document prototype object is "Object".

In the following descriptions of functions that are properties of the Document prototype object, the phrase "this Document object" refers to the object that is the result of applying ToDocument to the this value for the invocation of the function.

4.8.4.1 DOM.Document.prototype.constructor

The initial value of DOM.Document.prototype.constructor is the built-in Document constructor.

4.8.4.2 DOM.Document.prototype.createElement(tagName)

Creates an Element node with the tag name specified by tagName. Corresponds to the operation createElement of the Document interface specified by DOM.

4.8.4.3 DOM.Document.prototype.createDocumentFragment()

Creates an empty DocumentFragment node. Corresponds to the operation createDocumentFragment of the Document interface specified by DOM.

4.8.4.4 DOM.Document.prototype.createTextNode(data)

Creates a Text node with the value specified by data. Corresponds to the operation createTextNode of the Document interface specified by DOM.

4.8.4.5 DOM.Document.prototype.createComment(data)

Creates a Comment node with the value specified by data. Corresponds to the operation createComment of the Document interface specified by DOM.

4.8.4.6 DOM.Document.prototype.createCDATASection(data)

Creates a CDATASection node with the value specified by data. Corresponds to the operation createCDATASection of the Document interface specified by DOM.

4.8.4.7 DOM.Document.prototype.createProcessingInstruction(target, data)

Creates a ProcessingInstruction node with the name specified by target and the value specified by data. Corresponds to the operation createProcessingInstruction of the Document interface specified by DOM.

4.8.4.8 DOM.Document.prototype.createAttribute(name)

Creates an Attr node with the name specified by name. Corresponds to the operation createAttribute of the Document interface specified by DOM.

4.8.4.9 DOM.Document.prototype.cerateEntityReference(name)

Creates an EntityReference node with the name specified by name. Corresponds to the operation createEntityReference of the Document interface specified by DOM.

4.8.4.10 DOM.Document.prototype.getElementsByTagName(tagName)

Not supported by the current release of UESI (always returns null). Corresponds to the operation getElementsByTagName of the Document interface specified by DOM.

4.8.5 Properties of the Document Instances

The value of the internal [[Prototype]] property of the Document instance is the Document prototype object.

The value of the internal [[Class]] property of the Document instance is "DOM.Document".

The value of the internal [[Value]] property of the Document instance is the intrinsic object which implements Document interface specified by DOM.

DocumentFragment instances inherit properties from their [[Prototype]] object, have all properties specified for Node instances and also the following properties.

4.8.5.1 doctype

The DocumentType associated with this Document. Not supported in the current release of UESI (is always null). Corresponds to the doctype attribute of the Document interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.8.5.2 implementation

The DOMImplementation object associated with this Document. Corresponds to the implementation attribute of the Document interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.8.5.3 documentElement

The root Element of this Document. Corresponds to the documentElement attribute of the Document interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.9 CharacterData Objects

CharacterData objects implement bindings for CharacterData interface specified by DOM.

4.9.1 The CharacterData Constructor Called as a Function

When DOM.CharacterData is called as a function rather than a constructor, it performs a type conversion.

4.9.1.1 DOM.CharacterData(value)

Returns an object value computed by ToCharacterData( value ).

4.9.2 The CharacterData Constructor

When DOM.CharacterData is called as part of a new expression, it performs a type conversion rather than creation of a new object.

4.9.2.1 new DOM.CharacterData(value)

Returns an object value computed by ToCharacterData( value ).

4.9.3 Properties of the CharacterData Constructor

The value of the internal [[Prototype]] property of the CharacterData constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 1), the CharacterData constructor has the following properties.

4.9.3.1 DOM.CharacterData.prototype

The initial value of the DOM.CharacterData.prototype is the CharacterData prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.9.4 Properties of the CharacterData Prototype Object

The value of the internal [[Prototype]] property of the CharacterData prototype object is the Node prototype object. The value of the internal [[Class]] property of the CharacterData prototype object is "Object".

In the following descriptions of functions that are properties of the CharacterData prototype object, the phrase "this CharacterData object" refers to the object that is the result of applying ToCharacterData to the this value for the invocation of the function.

4.9.4.1 DOM.CharacterData.prototype.constructor

The initial value of DOM.CharacterData.prototype.constructor is the built-in CharacterData constructor.

4.9.4.2 DOM.CharacterData.prototype.substringData(offset, count)

Extracts a range of data from this CharacterData object. Corresponds to the operation substringData of the CharacterData interface specified by DOM.

4.9.4.3 DOM.CharacterData.prototype.appendData(arg)

Appends the string to the end of the character data of this CharacterData object. Corresponds to the operation appendData of the CharacterData interface specified by DOM.

4.9.4.4 DOM.CharacterData.prototype.insertData(offset, arg)

Inserts the string at the specified character offset into this CharacterData object. Corresponds to the operation insertData of the CharacterData interface specified by DOM.

4.9.4.5 DOM.CharacterData.prototype.deleteData(offset, count)

Removes a range of data from this CharacterData object. Corresponds to the operation deleteData of the CharacterData interface specified by DOM.

4.9.4.6 DOM.CharacterData.prototype.replaceData(offset, count, arg)

Replaces the characters started at the specified offset with the specified string in this CharacterData object. Corresponds to the operation replaceData of the CharacterData interface specified by DOM.

4.9.5 Properties of the CharacterData Instances

The value of the internal [[Prototype]] property of the CharacterData instance is the CharacterData prototype object.

The value of the internal [[Class]] property of the CharacterData instance is "DOM.CharacterData".

The value of the internal [[Value]] property of the CharacterData instance is the intrinsic object which implements CharacterData interface specified by DOM.

CharacterData instances inherit properties from their [[Prototype]] object, have all properties specified for Node instances and also the following properties.

4.9.5.1 data

The character data of this node. Corresponds to the data attribute of the CharacterData interface specified by DOM.

4.9.5.2 length

The length of the character data of this node. Corresponds to the length attribute of the CharacterData interface specified by DOM.

This property has the attributes { DontDelete, DontEnum, ReadOnly }.

4.10 Attr Objects

Attr objects implement bindings for Attr interface specified by DOM.

4.10.1 The Attr Constructor Called as a Function

When DOM.Attr is called as a function rather than a constructor, it performs a type conversion.

4.10.1.1 DOM.Attr(value)

Returns an object value computed by ToAttr( value ).

4.10.2 The Attr Constructor

When DOM.Attr is called as part of a new expression, it either creates a new object or performs a type conversion depending on the argument value.

4.10.2.1 new DOM.Attr(value [, name])

It value is an object whose [[Class]] property is "DOM.Document", a new Attr instance is constructed and returned. Otherwise, an object value computed by ToAttr( value ) is returned.

When the new Attr object is constructed, its [[Value]] property is set as follows.

Let D be an intrinsic object referenced by [[Value]] property of the value object. Let N be a string value computed by ToDOMString( name ). The operation createAttribute of the Document interface specified by DOM is applied to D with the argument N. Let A be an intrinsic object returned as the operation result. The [[Value]] property of the newly constructed object is set to A.

4.10.3 Properties of the Attr Constructor

The value of the internal [[Prototype]] property of the Attr constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 2), the Attr constructor has the following properties.

4.10.3.1 DOM.Attr.prototype

The initial value of the DOM.Attr.prototype is the Attr prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.10.4 Properties of the Attr Prototype Object

The value of the internal [[Prototype]] property of the Attr prototype object is the Node prototype object. The value of the internal [[Class]] property of the Attr prototype object is "Object".

4.10.4.1 DOM.Attr.prototype.constructor

The initial value of DOM.Attr.prototype.constructor is the built-in Attr constructor.

4.10.5 Properties of the Attr Instances

The value of the internal [[Prototype]] property of the Attr instance is the Attr prototype object.

The value of the internal [[Class]] property of the Attr instance is "DOM.Attr".

The value of the internal [[Value]] property of the Attr instance is the intrinsic object which implements Attr interface specified by DOM.

Attr instances inherit properties from their [[Prototype]] object, have all properties specified for Node instances and also the following properties.

4.10.5.1 name

Name of this attribute. Corresponds to the name attribute of the Attr interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.10.5.2 specified

Indicated whether this attribute was explicitly given a value in the original document. Not supported in the current release of UESI (is always true). Corresponds to the specified attribute of the Attr interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.10.5.3 value

The value of this attribute. Corresponds to the value attribute of the Attr interface specified by DOM.

4.11 Element Objects

Element objects implement bindings for Element interface specified by DOM.

4.11.1 The Element Constructor Called as a Function

When DOM.Element is called as a function rather than a constructor, it performs a type conversion.

4.11.1.1 DOM.Element(value)

Returns an object value computed by ToElement( value ).

4.11.2 The Element Constructor

When DOM.Element is called as part of a new expression, it either creates a new object or performs a type conversion depending on the argument value.

4.11.2.1 new DOM.Element(value [, tagName])

It value is an object whose [[Class]] property is "DOM.Document", a new Element instance is constructed and returned. Otherwise, an object value computed by ToElement( value ) is returned.

When the new Element object is constructed, its [[Value]] property is set as follows.

Let D be an intrinsic object referenced by [[Value]] property of the value object. Let N be a string value computed by ToDOMString( tagName ). The operation createElement of the Document interface specified by DOM is applied to D with the argument N. Let E be an intrinsic object returned as the operation result. The [[Value]] property of the newly constructed object is set to E.

4.11.3 Properties of the Element Constructor

The value of the internal [[Prototype]] property of the Element constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 2), the Element constructor has the following properties.

4.11.3.1 DOM.Element.prototype

The initial value of the DOM.Element.prototype is the Element prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.11.4 Properties of the Element Prototype Object

The value of the internal [[Prototype]] property of the Element prototype object is the Node prototype object. The value of the internal [[Class]] property of the Element prototype object is "Object".

In the following descriptions of functions that are properties of the Element prototype object, the phrase "this Element object" refers to the object that is the result of applying ToElement to the this value for the invocation of the function.

4.11.4.1 DOM.Element.prototype.constructor

The initial value of DOM.Element.prototype.constructor is the built-in Element constructor.

4.11.4.2 DOM.Element.prototype.getAttribute(name)

Retrieves an attribute value by name. Applies to this Element object. Corresponds to the operation getAttribute of the Element interface specified by DOM.

4.11.4.3 DOM.Element.prototype.setAttribute(name, value)

Sets a new attribute value. Applies to this Element object. Corresponds to the operation setAttribute of the Element interface specified by DOM.

4.11.4.4 DOM.Element.prototype.removeAttribute(name)

Removes an attribute by name. Applies this Element object. Corresponds to the operation removeAttribute of the Element interface specified by DOM.

4.11.4.5 DOM.Element.prototype.getAttributeNode(name)

Retrieves an attribute node by name. Applies to this Element object. Corresponds to the operation getAttributeNode of the Element interface specified by DOM.

4.11.4.6 DOM.Element.prototype.setAttributeNode(newAttr)

Sets a new attribute node. Applies to this Element object. Corresponds to the operation setAttributeNode of the Element interface specified by DOM.

4.11.4.7 DOM.Element.prototype.removeAttributeNode(oldAttr)

Removes the specified attribute node. Applies to this Element object. Corresponds to the operation removeAttributeNode of the Element interface specified by DOM.

4.11.4.8 DOM.Element.prototype.getElementsByTagName(name)

Not supported by the current release of UESI (always returns null). Corresponds to the operation getElementsByTagName of the Element interface specified by DOM.

4.11.5 Properties of the Element Instances

The value of the internal [[Prototype]] property of the Element instance is the Element prototype object.

The value of the internal [[Class]] property of the Element instance is "DOM.Element".

The value of the internal [[Value]] property of the Element instance is the intrinsic object which implements Element interface specified by DOM.

Element instances inherit properties from their [[Prototype]] object, have all properties specified for Node instances and also the following properties.

4.11.5.1 tagName

The name of this element. Corresponds to the tagName attribute of the Element interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.12 Text Objects

Text objects implement bindings for Text interface specified by DOM.

4.12.1 The Text Constructor Called as a Function

When DOM.Text is called as a function rather than a constructor, it performs a type conversion.

4.12.1.1 DOM.Text(value)

Returns an object value computed by ToText( value ).

4.12.2 The Text Constructor

When DOM.Text is called as part of a new expression, it either creates a new object or performs a type conversion depending on the argument value.

4.12.2.1 new DOM.Text(value [, data])

It value is an object whose [[Class]] property is "DOM.Document", a new Text instance is constructed and returned. Otherwise, an object value computed by ToText( value ) is returned.

When the new Text object is constructed, its [[Value]] property is set as follows.

Let D be an intrinsic object referenced by [[Value]] property of the value object. Let V be a string value computed by ToDOMString( data ). The operation createText of the Document interface specified by DOM is applied to D with the argument V. Let T be an intrinsic object returned as the operation result. The [[Value]] property of the newly constructed object is set to T.

4.12.3 Properties of the Text Constructor

The value of the internal [[Prototype]] property of the Text constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 2), the Text constructor has the following properties.

4.12.3.1 DOM.Text.prototype

The initial value of the DOM.Text.prototype is the Text prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.12.4 Properties of the Text Prototype Object

The value of the internal [[Prototype]] property of the Text prototype object is the CharacterData prototype object. The value of the internal [[Class]] property of the Text prototype object is "Object".

In the following descriptions of functions that are properties of the Text prototype object, the phrase "this Text object" refers to the object that is the result of applying ToText to the this value for the invocation of the function.

4.12.4.1 DOM.Text.prototype.constructor

The initial value of DOM.Text.prototype.constructor is the built-in Text constructor.

4.12.4.2 DOM.Text.prototype.splitText(offset)

Breaks node corresponding to this Text object into two nodes ate the specified offset offset. Corresponds to the operation splitText of the Text interface specified by DOM.

4.12.5 Properties of the Text Instances

The value of the internal [[Prototype]] property of the Text instance is the Text prototype object.

The value of the internal [[Class]] property of the Text instance is "DOM.Text".

The value of the internal [[Value]] property of the Text instance is the intrinsic object which implements Text interface specified by DOM.

Text instances inherit properties from their [[Prototype]] object and also have all properties specified for CharacterData instances.

4.13 Comment Objects

Comment objects implement bindings for Comment interface specified by DOM.

4.13.1 The Comment Constructor Called as a Function

When DOM.Comment is called as a function rather than a constructor, it performs a type conversion.

4.13.1.1 DOM.Comment(value)

Returns an object value computed by ToComment( value ).

4.13.2 The Comment Constructor

When DOM.Comment is called as part of a new expression, it either creates a new object or performs a type conversion depending on the argument value.

4.13.2.1 new DOM.Comment(value [, data])

It value is an object whose [[Class]] property is "DOM.Document", a new Comment instance is constructed and returned. Otherwise, an object value computed by ToComment( value ) is returned.

When the new Comment object is constructed, its [[Value]] property is set as follows.

Let D be an intrinsic object referenced by [[Value]] property of the value object. Let V be a string value computed by ToDOMString( data ). The operation createComment of the Document interface specified by DOM is applied to D with the argument V. Let C be an intrinsic object returned as the operation result. The [[Value]] property of the newly constructed object is set to C.

4.13.3 Properties of the Comment Constructor

The value of the internal [[Prototype]] property of the Comment constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 2), the Comment constructor has the following properties.

4.13.3.1 DOM.Comment.prototype

The initial value of the DOM.Comment.prototype is the Comment prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.13.4 Properties of the Comment Prototype Object

The value of the internal [[Prototype]] property of the Comment prototype object is the CharacterData prototype object. The value of the internal [[Class]] property of the Comment prototype object is "Object".

4.13.4.1 DOM.Comment.prototype.constructor

The initial value of DOM.Comment.prototype.constructor is the built-in Comment constructor.

4.13.5 Properties of the Comment Instances

The value of the internal [[Prototype]] property of the Comment instance is the Comment prototype object.

The value of the internal [[Class]] property of the Comment instance is "DOM.Comment".

The value of the internal [[Value]] property of the Comment instance is the intrinsic object which implements Comment interface specified by DOM.

Comment instances inherit properties from their [[Prototype]] object and also have all properties specified for CharacterData instances.

4.14 CDATASection Objects

CDATASection objects implement bindings for CDATASection interface specified by DOM.

4.14.1 The CDATASection Constructor Called as a Function

When DOM.CDATASection is called as a function rather than a constructor, it performs a type conversion.

4.14.1.1 DOM.CDATASection(value)

Returns an object value computed by ToCDATASection( value ).

4.14.2 The CDATASection Constructor

When DOM.CDATASection is called as part of a new expression, it either creates a new object or performs a type conversion depending on the argument value.

4.14.2.1 new DOM.CDATASection(value [, data])

It value is an object whose [[Class]] property is "DOM.Document", a new CDATASection instance is constructed and returned. Otherwise, an object value computed by ToCDATASection( value ) is returned.

When the new CDATASection object is constructed, its [[Value]] property is set as follows.

Let D be an intrinsic object referenced by [[Value]] property of the value object. Let V be a string value computed by ToDOMString( data ). The operation createCDATASection of the Document interface specified by DOM is applied to D with the argument V. Let C be an intrinsic object returned as the operation result. The [[Value]] property of the newly constructed object is set to C.

4.14.3 Properties of the CDATASection Constructor

The value of the internal [[Prototype]] property of the CDATASection constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 2), the CDATASection constructor has the following properties.

4.14.3.1 DOM.CDATASection.prototype

The initial value of the DOM.CDATASection.prototype is the CDATASection prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.14.4 Properties of the CDATASection Prototype Object

The value of the internal [[Prototype]] property of the CDATASection prototype object is the Text prototype object. The value of the internal [[Class]] property of the CDATASection prototype object is "Object".

4.14.4.1 DOM.CDATASection.prototype.constructor

The initial value of DOM.CDATASection.prototype.constructor is the built-in CDATASection constructor.

4.14.5 Properties of the CDATASection Instances

The value of the internal [[Prototype]] property of the CDATASection instance is the CDATASection prototype object.

The value of the internal [[Class]] property of the CDATASection instance is "DOM.CDATASection".

The value of the internal [[Value]] property of the CDATASection instance is the intrinsic object which implements CDATASection interface specified by DOM.

CDATASection instances inherit properties from their [[Prototype]] object and also have all properties specified for Text instances.

4.15 EntityReference Objects

EntityReference objects implement bindings for EntityReference interface specified by DOM.

4.15.1 The EntityReference Constructor Called as a Function

When DOM.EntityReference is called as a function rather than a constructor, it performs a type conversion.

4.15.1.1 DOM.EntityReference(value)

Returns an object value computed by ToEntityReference( value ).

4.15.2 The EntityReference Constructor

When DOM.EntityReference is called as part of a new expression, it either creates a new object or performs a type conversion depending on the argument value.

4.15.2.1 new DOM.EntityReference(value [, name])

It value is an object whose [[Class]] property is "DOM.Document", a new EntityReference instance is constructed and returned. Otherwise, an object value computed by ToEntityReference( value ) is returned.

When the new EntityReference object is constructed, its [[Value]] property is set as follows.

Let D be an intrinsic object referenced by [[Value]] property of the value object. Let N be a string value computed by ToDOMString( name ). The operation createComment of the Document interface specified by DOM is applied to D with the argument N. Let R be an intrinsic object returned as the operation result. The [[Value]] property of the newly constructed object is set to R.

4.15.3 Properties of the EntityReference Constructor

The value of the internal [[Prototype]] property of the EntityReference constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 2), the EntityReference constructor has the following properties.

4.15.3.1 DOM.EntityReference.prototype

The initial value of the DOM.EntityReference.prototype is the EntityReference prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.15.4 Properties of the EntityReference Prototype Object

The value of the internal [[Prototype]] property of the EntityReference prototype object is the Node prototype object. The value of the internal [[Class]] property of the EntityReference prototype object is "Object".

4.15.4.1 DOM.EntityReference.prototype.constructor

The initial value of DOM.EntityReference.prototype.constructor is the built-in EntityReference constructor.

4.15.5 Properties of the EntityReference Instances

The value of the internal [[Prototype]] property of the EntityReference instance is the EntityReference prototype object.

The value of the internal [[Class]] property of the EntityReference instance is "DOM.EntityReference".

The value of the internal [[Value]] property of the EntityReference instance is the intrinsic object which implements EntityReference interface specified by DOM.

EntityReference instances inherit properties from their [[Prototype]] object and also have all properties specified for Node instances.

4.16 ProcessingInstruction Objects

ProcessingInstruction objects implement bindings for ProcessingInstruction interface specified by DOM.

4.16.1 The ProcessingInstruction Constructor Called as a Function

When DOM.ProcessingInstruction is called as a function rather than a constructor, it performs a type conversion.

4.16.1.1 DOM.ProcessingInstruction(value)

Returns an object value computed by ToProcessingInstruction( value ).

4.16.2 The ProcessingInstruction Constructor

When DOM.ProcessingInstruction is called as part of a new expression, it either creates a new object or performs a type conversion depending on the argument value.

4.16.2.1 new DOM.ProcessingInstruction(value [, target, data])

It value is an object whose [[Class]] property is "DOM.Document", a new ProcessingInstruction instance is constructed and returned. Otherwise, an object value computed by ToProcessingInstruction( value ) is returned.

When the new ProcessingInstruction object is constructed, its [[Value]] property is set as follows.

Let D be an intrinsic object referenced by [[Value]] property of the value object. Let N be a string value computed by ToDOMString( target ). Let V be a string value computed by ToDOMString( data ). The operation createProcessingInstruction of the Document interface specified by DOM is applied to D with the arguments (N, V). Let P be an intrinsic object returned as the operation result. The [[Value]] property of the newly constructed object is set to P.

4.16.3 Properties of the ProcessingInstruction Constructor

The value of the internal [[Prototype]] property of the ProcessingInstruction constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 3), the ProcessingInstruction constructor has the following properties.

4.16.3.1 DOM.ProcessingInstruction.prototype

The initial value of the DOM.ProcessingInstruction.prototype is the ProcessingInstruction prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.16.4 Properties of the ProcessingInstruction Prototype Object

The value of the internal [[Prototype]] property of the ProcessingInstruction prototype object is the Node prototype object. The value of the internal [[Class]] property of the ProcessingInstruction prototype object is "Object".

4.16.4.1 DOM.ProcessingInstruction.prototype.constructor

The initial value of DOM.ProcessingInstruction.prototype.constructor is the built-in ProcessingInstruction constructor.

4.16.5 Properties of the ProcessingInstruction Instances

The value of the internal [[Prototype]] property of the ProcessingInstruction instance is the ProcessingInstruction prototype object.

The value of the internal [[Class]] property of the ProcessingInstruction instance is "DOM.ProcessingInstruction".

The value of the internal [[Value]] property of the ProcessingInstruction instance is the intrinsic object which implements ProcessingInstruction interface specified by DOM.

ProcessingInstruction instances inherit properties from their [[Prototype]] object, have all properties specified for Node instances and also the following properties.

4.16.5.1 target

The target of this processing instruction Corresponds to the target attribute of the ProcessingInstruction interface specified by DOM.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.16.5.2 data

The content of this processing instruction. Corresponds to the data attribute of the ProcessingInstruction interface specified by DOM.

4.17 Reader Objects

Reader objects are designed to traverse the DOM subtree in the document order, generating the appropriate stream of SAX2 events. Reader objects implement XML Stream interface (their prototype chain contains the Stream prototype) and can be used in any context where XML Stream is required.

Note that Reader objects read data from DOM subtrees.

Reader objects do not implement any specific DOM interface.

4.17.1 The Reader Constructor Called as a Function

Not supported in the current release of UESI. Reserved for the future.

4.17.1.1 DOM.Reader([node])

Not supported in the current release of UESI. Generates the runtime error.

4.17.2 The Reader Constructor

When DOM.Reader is called as part of a new expression, it is a constructor: it initializes the newly created Reader instance.

4.17.2.1 new DOM.Reader([node])

If node is undefined let N be null value; otherwise let N be an object value computed by ToNode( node ).

The node property of the newly created Reader instance is set to N.

The namespaces property of the newly created Reader instance is set to true.

4.17.3 Properties of the Reader Constructor

The value of the internal [[Prototype]] property of the Reader constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 1), the Reader constructor has the following properties.

4.17.3.1 DOM.Reader.prototype

The initial value of the DOM.Reader.prototype is the Reader prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.17.4 Properties of the Reader Prototype Object

The Reader prototype object is itself a Reader object (its [[Class]] is "DOM.Reader") whose node property is null and namespaces property is true.

The value of the internal [[Prototype]] property of the Reader prototype object is the XML Stream prototype object (the initial value of XML.Stream.prototype).

4.17.4.1 DOM.Reader.prototype.constructor

The initial value of DOM.Reader.prototype.constructor is the built-in Reader constructor.

4.17.5 Properties of the Reader Instances

The value of the internal [[Prototype]] property of the Reader instance is the Reader prototype object.

The value of the internal [[Class]] property of the Reader instance is "DOM.Reader".

Reader instances inherit properties from their [[Prototype]] object, have all properties specified for XML Stream instances and also the following properties.

4.17.5.1 node

This property specifies the root node for this reader. It must be a Node object (the intrinsic object referenced by its [[Value]] property must implement Node interface). This node specifies the root of the DOM tree that is to be traversed by XML.Stream.prototype.start function applied to this Reader instance.

4.17.5.2 namespaces

The boolean value which specifies whether the reader generates namespace information in the output stream of events.

4.17.5.3 XML.Stream.prototype.start Applied to Reader Instances

When the Stream prototype function XML.Stream.prototype.start is applied to the Reader instance, it is traversing of the DOM subtree rooted at node (inclusive the node itself) in the document order. For every DOM node visited, the appropriate SAX2 events are generated and passed to the related contentHandler for the further processing.

4.18 Writer Objects

Writer objects are designed to process the stream of SAX2 events, creating a set of DOM nodes and appending these nodes to the children list of a given root node. Writer objects implement XML ContentHandler interface (their prototype chains contain ContentHandler protype) and can be used in any context where XML ContentHandler is required.

Note that Writer objects write data to DOM subtrees.

Writer objects do not implement any specific DOM interface.

4.18.1 The Writer Constructor Called as a Function

Not supported in the current release of UESI. Reserved for the future.

4.18.1.1 DOM.Writer([node])

Not supported in the current release of UESI. Generates the runtime error.

4.18.2 The Writer Constructor

When DOM.Writer is called as part of a new expression, it is a constructor: it initializes the newly created Writer instance.

4.18.2.1 new DOM.Writer([node])

If node is undefined let N be null value; otherwise let N be an object value computed by ToNode( node ).

The node property of the newly created Writer instance is set to N.

The namespaces property of the newly created Writer instance is set to true.

4.18.3 Properties of the Writer Constructor

The value of the internal [[Prototype]] property of the Writer constructor is the Function prototype object.

Besides the internal properties and the length property (whose value is 1), the Writer constructor has the following properties.

4.18.3.1 DOM.Writer.prototype

The initial value of the DOM.Writer.prototype is the Writer prototype object.

This property has the attributes { DontEnum, DontDelete, ReadOnly }.

4.18.4 Properties of the Writer Prototype Object

The Writer prototype object is itself a Writer object (its [[Class]] is "DOM.Writer") whose node property is null and namespaces property is true.

The value of the internal [[Prototype]] property of the Writer prototype object is the XML ContentHandler prototype object (the initial value of XML.ContentHandler.prototype).

4.18.4.1 DOM.Writer.prototype.constructor

The initial value of DOM.Writer.prototype.constructor is the built-in Writer constructor.

4.18.5 Properties of the Writer Instances

The value of the internal [[Prototype]] property of the Writer instance is the Writer prototype object.

The value of the internal [[Class]] property of the Writer instance is "DOM.Writer".

Writer instances inherit properties from their [[Prototype]] object, have all properties specified for XML ContentHandler instances and also the following properties.

4.18.5.1 node

This property specifies the root base node for this writer. It must be a Node object (the intrinsic object referenced by its [[Value]] property must implement Node interface). Top-level nodes created by the ContentHandler functions of this Writer instance will be appended to the children list of this node.

4.18.5.2 namespaces

The boolean value which specifies whether the writer is expected to support namespace information in the source stream of events. The ECMAScript program must assign this property the same value which is set for the namespaces property of the related Stream object.


Appendices

A References

[ECMA-262] ECMA. Standard ECMA-262 2nd Edition - August 1998. ECMAScript Language Specification. See http://www.ecma.ch
[XML] World Wide Web Consortium. Extensible Markup Language (XML) 1.0. W3C Recommendation 10-February-1998 (REC-xml-19980210). See http://www.w3.org/TR/REC-xml
[DOM] World Wide Web Consortium. Document Object Model (DOM) Level 1 Specification Version 1.0. W3C Recommendation 1 October, 1998 (REC-DOM-Level-1-19981001). See http://www.w3.org/TR/REC-DOM-Level-1
[SAX2] Megginson Technologies. SAX 2.0: The Simple API for XML. See http://www.megginson.com/SAX/index.html
[UESI-XML] Unicorn Enterprises SA. Unicorn ECMAScript Interpreter Reference Manual. XML Extensions. Version 2.0. 31 October 2000. See https://www.unicorn-enterprises.com/esxxml.htm

B Examples

Example 1.

This sample script creates a DOM document, then traverses the document tree, displaying various characteristics of each visited document node.

  var doc = new DOM.Document();
  var elem;
  var attr;
  var text;
  var temp;
  elem = doc.createElement("root");
  doc.appendChild(elem);
  temp = elem;
  for (var i = 0; i < 3; i++) {
      elem = doc.createElement("p");
      temp.appendChild(elem);
      elem.setAttribute("id", String(i+1));
      attr = doc.createAttribute("width");
      attr.value = String(100+10*i);
      elem.setAttributeNode(attr);
      text = doc.createTextNode("Text-"+(i+1));
      elem.appendChild(text);
      }
  walk(doc);
  function walk(node) {
      print("Name: "+node.nodeName+
          ", value: "+node.nodeValue+
          ", type: "+node.nodeType);
      var type = node.nodeType;
      if (type == DOM.Node.ELEMENT_NODE) {
          var attrMap = node.attributes;
          var length = attrMap.length;
          for (var i = 0; i < length; i++)
              walk(attrMap.item(i));
          }
      if (type == DOM.Node.DOCUMENT_NODE || 
              type == DOM.Node.ELEMENT_NODE) {
          for (var child = node.firstChild; 
                  child != null; child = child.nextSibling)
              walk(child);
          }
      }

Example 2.

This sample script creates a simple document using DOM. Then it creates the DOM reader and the XML writer objects and uses them to write this document to the output file.

  var baseURI = "file://localhost/d/uxsl/bin/uxp/samples/";
  var outName = "uxpdom02.out";
  var doc = new DOM.Document();
  var elem;
  var attr;
  var text;
  var temp;
  elem = doc.createElement("root");
  doc.appendChild(elem);
  temp = elem;
  for (var i = 0; i < 3; i++) {
      elem = doc.createElement("p");
      temp.appendChild(elem);
      elem.setAttribute("id", String(i+1));
      attr = doc.createAttribute("width");
      attr.value = String(100+10*i);
      elem.setAttributeNode(attr);
      text = doc.createTextNode("Text-"+(i+1));
      elem.appendChild(text);
      }
  var dr = new DOM.Reader(doc);
  var xw = new XML.Writer();
  dr.contentHandler = xw;
  xw.URI = baseURI + outName;
  xw.indent = true;
  dr.start();

Example 3.

This sample script creates an empty DOM document, XML reader and DOM writer objects, connects them and performs parsing of the XML document, storing the result in the DOM document. Then it creates the DOM reader and the XML writer objects and uses them to write this document to the output file.

  var baseURI = "file://localhost/d/uxsl/bin/uxp/samples/";
  var fileName = "uxpdom03.xml";
  var outName = "uxpdom03.out";
  var d = new DOM.Document();
  var xr = new XML.Reader();
  var dw = new DOM.Writer(d);
  xr.contentHandler = dw;
  xr.parse(baseURI+fileName);
  var dr = new DOM.Reader(d);
  var xw = new XML.Writer();
  dr.contentHandler = xw;
  xw.URI = baseURI + outName;
  dr.start();