13 November, 2000

# Appendix C: ECMAScript Language Binding

This appendix contains the complete ECMAScript [ECMAScript] binding for the Level 2 Document Object Model Traversal and Range definitions. The definitions are divided into Traversal, and Range.

Note: Exceptions handling is only supported by ECMAScript implementation conformant with the Standard ECMA-262 3rd. Edition ([ECMAScript]).

## C.1: Document Object Model Traversal

Object NodeIterator
  The NodeIterator object has the following properties:
    root
      This read-only property is a Node object.
    whatToShow
      This read-only property is of type Number.
    filter
      This read-only property is a NodeFilter object.
    expandEntityReferences
      This read-only property is of type Boolean.
  The NodeIterator object has the following methods:
    nextNode()
      This method returns a Node object.
      This method can raise a DOMException object.
    previousNode()
      This method returns a Node object.
      This method can raise a DOMException object.
    detach()
      This method has no return value.
Prototype Object NodeFilter
  The NodeFilter class has the following constants:
    NodeFilter.FILTER_ACCEPT
      This constant is of type short and its value is 1.
    NodeFilter.FILTER_REJECT
      This constant is of type short and its value is 2.
    NodeFilter.FILTER_SKIP
      This constant is of type short and its value is 3.
    NodeFilter.SHOW_ALL
      This constant is of type Number and its value is 0xFFFFFFFF.
    NodeFilter.SHOW_ELEMENT
      This constant is of type Number and its value is 0x00000001.
    NodeFilter.SHOW_ATTRIBUTE
      This constant is of type Number and its value is 0x00000002.
    NodeFilter.SHOW_TEXT
      This constant is of type Number and its value is 0x00000004.
    NodeFilter.SHOW_CDATA_SECTION
      This constant is of type Number and its value is 0x00000008.
    NodeFilter.SHOW_ENTITY_REFERENCE
      This constant is of type Number and its value is 0x00000010.
    NodeFilter.SHOW_ENTITY
      This constant is of type Number and its value is 0x00000020.
    NodeFilter.SHOW_PROCESSING_INSTRUCTION
      This constant is of type Number and its value is 0x00000040.
    NodeFilter.SHOW_COMMENT
      This constant is of type Number and its value is 0x00000080.
    NodeFilter.SHOW_DOCUMENT
      This constant is of type Number and its value is 0x00000100.
    NodeFilter.SHOW_DOCUMENT_TYPE
      This constant is of type Number and its value is 0x00000200.
    NodeFilter.SHOW_DOCUMENT_FRAGMENT
      This constant is of type Number and its value is 0x00000400.
    NodeFilter.SHOW_NOTATION
      This constant is of type Number and its value is 0x00000800.
Object NodeFilter
  This is an ECMAScript function reference. This method returns a Number. The parameter is a Node object.
Object TreeWalker
  The TreeWalker object has the following properties:
    root
      This read-only property is a Node object.
    whatToShow
      This read-only property is of type Number.
    filter
      This read-only property is a NodeFilter object.
    expandEntityReferences
      This read-only property is of type Boolean.
    currentNode
      This property is a Node object and can raise a DOMException object on setting.
  The TreeWalker object has the following methods:
    parentNode()
      This method returns a Node object.
    firstChild()
      This method returns a Node object.
    lastChild()
      This method returns a Node object.
    previousSibling()
      This method returns a Node object.
    nextSibling()
      This method returns a Node object.
    previousNode()
      This method returns a Node object.
    nextNode()
      This method returns a Node object.
Object DocumentTraversal
  The DocumentTraversal object has the following methods:
    createNodeIterator(root, whatToShow, filter, entityReferenceExpansion)
      This method returns a NodeIterator object.
      The root parameter is a Node object.
      The whatToShow parameter is of type Number.
      The filter parameter is a NodeFilter object.
      The entityReferenceExpansion parameter is of type Boolean.
      This method can raise a DOMException object.
    createTreeWalker(root, whatToShow, filter, entityReferenceExpansion)
      This method returns a TreeWalker object.
      The root parameter is a Node object.
      The whatToShow parameter is of type Number.
      The filter parameter is a NodeFilter object.
      The entityReferenceExpansion parameter is of type Boolean.
      This method can raise a DOMException object.

## C.2: Document Object Model Range

Prototype Object Range
  The Range class has the following constants:
    Range.START_TO_START
      This constant is of type Number and its value is 0.
    Range.START_TO_END
      This constant is of type Number and its value is 1.
    Range.END_TO_END
      This constant is of type Number and its value is 2.
    Range.END_TO_START
      This constant is of type Number and its value is 3.
Object Range
  The Range object has the following properties:
    startContainer
      This read-only property is a Node object and can raise a DOMException object on retrieval.
    startOffset
      This read-only property is a long object and can raise a DOMException object on retrieval.
    endContainer
      This read-only property is a Node object and can raise a DOMException object on retrieval.
    endOffset
      This read-only property is a long object and can raise a DOMException object on retrieval.
    collapsed
      This read-only property is of type Boolean and can raise a DOMException object on retrieval.
    commonAncestorContainer
      This read-only property is a Node object and can raise a DOMException object on retrieval.
  The Range object has the following methods:
    setStart(refNode, offset)
      This method has no return value.
      The refNode parameter is a Node object.
      The offset parameter is a long object.
      This method can raise a RangeException object or a DOMException object.
    setEnd(refNode, offset)
      This method has no return value.
      The refNode parameter is a Node object.
      The offset parameter is a long object.
      This method can raise a RangeException object or a DOMException object.
    setStartBefore(refNode)
      This method has no return value.
      The refNode parameter is a Node object.
      This method can raise a RangeException object or a DOMException object.
    setStartAfter(refNode)
      This method has no return value.
      The refNode parameter is a Node object.
      This method can raise a RangeException object or a DOMException object.
    setEndBefore(refNode)
      This method has no return value.
      The refNode parameter is a Node object.
      This method can raise a RangeException object or a DOMException object.
    setEndAfter(refNode)
      This method has no return value.
      The refNode parameter is a Node object.
      This method can raise a RangeException object or a DOMException object.
    collapse(toStart)
      This method has no return value.
      The toStart parameter is of type Boolean.
      This method can raise a DOMException object.
    selectNode(refNode)
      This method has no return value.
      The refNode parameter is a Node object.
      This method can raise a RangeException object or a DOMException object.
    selectNodeContents(refNode)
      This method has no return value.
      The refNode parameter is a Node object.
      This method can raise a RangeException object or a DOMException object.
    compareBoundaryPoints(how, sourceRange)
      This method returns a short object.
      The how parameter is of type Number.
      The sourceRange parameter is a Range object.
      This method can raise a DOMException object.
    deleteContents()
      This method has no return value.
      This method can raise a DOMException object.
    extractContents()
      This method returns a DocumentFragment object.
      This method can raise a DOMException object.
    cloneContents()
      This method returns a DocumentFragment object.
      This method can raise a DOMException object.
    insertNode(newNode)
      This method has no return value.
      The newNode parameter is a Node object.
      This method can raise a DOMException object or a RangeException object.
    surroundContents(newParent)
      This method has no return value.
      The newParent parameter is a Node object.
      This method can raise a DOMException object or a RangeException object.
    cloneRange()
      This method returns a Range object.
      This method can raise a DOMException object.
    toString()
      This method returns a String.
      This method can raise a DOMException object.
    detach()
      This method has no return value.
      This method can raise a DOMException object.
Object DocumentRange
  The DocumentRange object has the following methods:
    createRange()
      This method returns a Range object.
Prototype Object RangeException
  The RangeException class has the following constants:
    RangeException.BAD_BOUNDARYPOINTS_ERR
      This constant is of type Number and its value is 1.
    RangeException.INVALID_NODE_TYPE_ERR
      This constant is of type Number and its value is 2.
Object RangeException
  The RangeException object has the following properties:
    code
      This property is of type Number.