📄 document.jsc
字号:
# language: jsvm2/* * Copyright (c) 2000 World Wide Web Consortium, * (Massachusetts Institute of Technology, Institut National de * Recherche en Informatique et en Automatique, Keio University). All * Rights Reserved. This program is distributed under the W3C's Software * Intellectual Property License. This program is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. * See W3C License http://www.w3.org/Consortium/Legal/ for more details. */package org.w3c.dom;import js.util.HashMap;import org.w3c.dom.Node;/** * The <code>Document</code> interface represents the entire HTML or XML * document. Conceptually, it is the root of the document tree, and provides * the primary access to the document's data. * <p>Since elements, text nodes, comments, processing instructions, etc. * cannot exist outside the context of a <code>Document</code>, the * <code>Document</code> interface also contains the factory methods needed * to create these objects. The <code>Node</code> objects created have a * <code>ownerDocument</code> attribute which associates them with the * <code>Document</code> within whose context they were created. * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>. */class Document extends Node (){ super.call(this, Node.DOCUMENT_NODE); this.__elementMap = new HashMap();}/** * The Document Type Declaration (see <code>DocumentType</code>) * associated with this document. For HTML documents as well as XML * documents without a document type declaration this returns * <code>null</code>. The DOM Level 2 does not support editing the * Document Type Declaration. <code>docType</code> cannot be altered in * any way, including through the use of methods inherited from the * <code>Node</code> interface, such as <code>insertNode</code> or * <code>removeNode</code>. */Document.prototype.getDoctype = function (){ //TODO}/** * The <code>DOMImplementation</code> object that handles this document. A * DOM application may use objects from multiple implementations. */Document.prototype.getImplementation = function (){ //TODO}/** * This is a convenience attribute that allows direct access to the child * node that is the root element of the document. For HTML documents, * this is the element with the tagName "HTML". */Document.prototype.getDocumentElement = function (){ //TODO}/** * Creates an element of the type specified. Note that the instance * returned implements the <code>Element</code> interface, so attributes * can be specified directly on the returned object. * <br>In addition, if there are known attributes with default values, * <code>Attr</code> nodes representing them are automatically created * and attached to the element. * <br>To create an element with a qualified name and namespace URI, use * the <code>createElementNS</code> method. * @param tagName The name of the element type to instantiate. For XML, * this is case-sensitive. For HTML, the <code>tagName</code> * parameter may be provided in any case, but it must be mapped to the * canonical uppercase form by the DOM implementation. * @return A new <code>Element</code> object with the * <code>nodeName</code> attribute set to <code>tagName</code>, and * <code>localName</code>, <code>prefix</code>, and * <code>namespaceURI</code> set to <code>null</code>. * @exception DOMException * INVALID_CHARACTER_ERR: Raised if the specified name contains an * illegal character. */Document.prototype.createElement = function (tagName){ //TODO}/** * Creates a <code>Text</code> node given the specified string. * @param data The data for the node. * @return The new <code>Text</code> object. */Document.prototype.createTextNode = function (data){ //TODO}/** * Creates an <code>Attr</code> of the given name. Note that the * <code>Attr</code> instance can then be set on an <code>Element</code> * using the <code>setAttributeNode</code> method. * <br>To create an attribute with a qualified name and namespace URI, use * the <code>createAttributeNS</code> method. * @param name The name of the attribute. * @return A new <code>Attr</code> object with the <code>nodeName</code> * attribute set to <code>name</code>, and <code>localName</code>, * <code>prefix</code>, and <code>namespaceURI</code> set to * <code>null</code>. The value of the attribute is the empty string. * @exception DOMException * INVALID_CHARACTER_ERR: Raised if the specified name contains an * illegal character. */Document.prototype.createAttribute = function (name){ //TODO}/** * Returns a <code>NodeList</code> of all the <code>Elements</code> with a * given tag name in the order in which they are encountered in a * preorder traversal of the <code>Document</code> tree. * @param tagname The name of the tag to match on. The special value "*" * matches all tags. * @return A new <code>NodeList</code> object containing all the matched * <code>Elements</code>. */Document.prototype.getElementsByTagName = function (tagName){ }/** * Returns the <code>Element</code> whose <code>ID</code> is given by * <code>elementId</code>. If no such element exists, returns * <code>null</code>. Behavior is not defined if more than one element * has this <code>ID</code>. The DOM implementation must have * information that says which attributes are of type ID. Attributes * with the name "ID" are not of type ID unless so defined. * Implementations that do not know whether attributes are of type ID or * not are expected to return <code>null</code>. * @param elementId The unique <code>id</code> value for an element. * @return The matching element. * @since DOM Level 2 */Document.prototype.getElementById = function (elementId){ return this.__elementMap.get(elementId);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -