Source code

Revision control

Copy as Markdown

Other Tools

/*
* Copyright 2008 The Closure Compiler Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Definitions for W3C's DOM Level 1 specification.
* The whole file has been fully type annotated. Created from
*
* @externs
* @author stevey@google.com (Steve Yegge)
*/
/**
* @constructor
*/
function DOMException() {}
/**
* @type {number}
*/
DOMException.INDEX_SIZE_ERR = 1;
/**
* @type {number}
*/
DOMException.DOMSTRING_SIZE_ERR = 2;
/**
* @type {number}
*/
DOMException.HIERARCHY_REQUEST_ERR = 3;
/**
* @type {number}
*/
DOMException.WRONG_DOCUMENT_ERR = 4;
/**
* @type {number}
*/
DOMException.INVALID_CHARACTER_ERR = 5;
/**
* @type {number}
*/
DOMException.NO_DATA_ALLOWED_ERR = 6;
/**
* @type {number}
*/
DOMException.NO_MODIFICATION_ALLOWED_ERR = 7;
/**
* @type {number}
*/
DOMException.NOT_FOUND_ERR = 8;
/**
* @type {number}
*/
DOMException.NOT_SUPPORTED_ERR = 9;
/**
* @type {number}
*/
DOMException.INUSE_ATTRIBUTE_ERR = 10;
/**
* @constructor
*/
function ExceptionCode() {}
/**
* @constructor
*/
function DOMImplementation() {}
/**
* @param {string} feature
* @param {string} version
* @return {boolean}
* @nosideeffects
*/
DOMImplementation.prototype.hasFeature = function(feature, version) {};
/**
* @constructor
* @implements {EventTarget}
*/
function Node() {}
/**
* @param {boolean=} opt_useCapture
* @override
*/
Node.prototype.addEventListener = function(type, listener, opt_useCapture) {};
/**
* @param {boolean=} opt_useCapture
* @override
*/
Node.prototype.removeEventListener = function(type, listener, opt_useCapture) {};
/** @override */
Node.prototype.dispatchEvent = function(evt) {};
/**
* @type {NamedNodeMap}
*/
Node.prototype.attributes;
/**
* @type {!NodeList}
*/
Node.prototype.childNodes;
/**
* @type {Node}
*/
Node.prototype.firstChild;
/**
* @type {Node}
*/
Node.prototype.lastChild;
/**
* @type {Node}
*/
Node.prototype.nextSibling;
/**
* @type {string}
*/
Node.prototype.nodeName;
/**
* @type {string}
*/
Node.prototype.nodeValue;
/**
* @type {number}
*/
Node.prototype.nodeType;
/**
* @type {Document}
*/
Node.prototype.ownerDocument;
/**
* @type {Node}
*/
Node.prototype.parentNode;
/**
* @type {Node}
*/
Node.prototype.previousSibling;
/**
* @param {Node} newChild
* @return {Node}
*/
Node.prototype.appendChild = function(newChild) {};
/**
* @param {boolean} deep
* @return {!Node}
* @nosideeffects
*/
Node.prototype.cloneNode = function(deep) {};
/**
* @return {boolean}
* @nosideeffects
*/
Node.prototype.hasChildNodes = function() {};
/**
* @param {Node} newChild
* @param {Node} refChild
* @return {!Node}
*/
Node.prototype.insertBefore = function(newChild, refChild) {};
/**
* @param {Node} oldChild
* @return {!Node}
*/
Node.prototype.removeChild = function(oldChild) {};
/**
* @param {Node} newChild
* @param {Node} oldChild
* @return {!Node}
*/
Node.prototype.replaceChild = function(newChild, oldChild) {};
/**
* @type {number}
*/
Node.ATTRIBUTE_NODE;
/**
* @type {number}
*/
Node.CDATA_SECTION_NODE;
/**
* @type {number}
*/
Node.COMMENT_NODE;
/**
* @type {number}
*/
Node.DOCUMENT_FRAGMENT_NODE;
/**
* @type {number}
*/
Node.DOCUMENT_NODE;
/**
* @type {number}
*/
Node.DOCUMENT_TYPE_NODE;
/**
* @type {number}
*/
Node.ELEMENT_NODE;
/**
* @type {number}
*/
Node.ENTITY_NODE;
/**
* @type {number}
*/
Node.ENTITY_REFERENCE_NODE;
/**
* @type {number}
*/
Node.PROCESSING_INSTRUCTION_NODE;
/**
* @type {number}
*/
Node.TEXT_NODE;
/**
* @type {number}
*/
Node.XPATH_NAMESPACE_NODE;
/**
* @type {number}
*/
Node.NOTATION_NODE;
/**
* @constructor
* @extends {Node}
*/
function DocumentFragment() {}
/**
* @constructor
* @extends {Node}
*/
function Document() {}
/**
* @type {DocumentType}
*/
Document.prototype.doctype;
/**
* @type {!Element}
*/
Document.prototype.documentElement;
/**
* @type {DOMImplementation}
*/
Document.prototype.implementation;
/**
* @param {string} name
* @return {!Attr}
* @nosideeffects
*/
Document.prototype.createAttribute = function(name) {};
/**
* @param {string} data
* @return {!Comment}
* @nosideeffects
*/
Document.prototype.createComment = function(data) {};
/**
* @param {string} data
* @return {!CDATASection}
* @nosideeffects
*/
Document.prototype.createCDATASection = function(data) {};
/**
* @return {!DocumentFragment}
* @nosideeffects
*/
Document.prototype.createDocumentFragment = function() {};
/**
* Create a DOM element.
*
* Web components introduced the second parameter as a way of extending existing
* tags (e.g. document.createElement('button', 'fancy-button')).
*
* @param {string} tagName
* @param {string=} opt_typeExtension
* @return {!Element}
* @nosideeffects
*/
Document.prototype.createElement = function(tagName, opt_typeExtension) {};
/**
* @param {string} name
* @return {!EntityReference}
* @nosideeffects
*/
Document.prototype.createEntityReference = function(name) {};
/**
* @param {string} target
* @param {string} data
* @return {!ProcessingInstruction}
* @nosideeffects
*/
Document.prototype.createProcessingInstruction = function(target, data) {};
/**
* @param {number|string} data
* @return {!Text}
* @nosideeffects
*/
Document.prototype.createTextNode = function(data) {};
/**
* @param {string} tagname
* @return {!NodeList}
* @nosideeffects
*/
Document.prototype.getElementsByTagName = function(tagname) {};
/**
* @constructor
*/
function NodeList() {}
/**
* @type {number}
*/
NodeList.prototype.length;
/**
* @param {number} index
* @return {Node}
*/
NodeList.prototype.item = function(index) {};
/**
* @constructor
*/
function NamedNodeMap() {}
/**
* @type {number}
*/
NamedNodeMap.prototype.length;
/**
* @param {string} name
* @return {Node}
* @nosideeffects
*/
NamedNodeMap.prototype.getNamedItem = function(name) {};
/**
* @param {number} index
* @return {Node}
* @nosideeffects
*/
NamedNodeMap.prototype.item = function(index) {};
/**
* @param {string} name
* @return {Node}
*/
NamedNodeMap.prototype.removeNamedItem = function(name) {};
/**
* @param {Node} arg
* @return {Node}
*/
NamedNodeMap.prototype.setNamedItem = function(arg) {};
/**
* @constructor
* @extends {Node}
*/
function CharacterData() {}
/**
* @type {string}
*/
CharacterData.prototype.data;
/**
* @type {number}
*/
CharacterData.prototype.length;
/**
* @param {string} arg
* @return {undefined}
*/
CharacterData.prototype.appendData = function(arg) {};
/**
* @param {number} offset
* @param {number} count
* @return {undefined}
*/
CharacterData.prototype.deleteData = function(offset, count) {};
/**
* @param {number} offset
* @param {string} arg
* @return {undefined}
*/
CharacterData.prototype.insertData = function(offset, arg) {};
/**
* @param {number} offset
* @param {number} count
* @param {string} arg
* @return {undefined}
*/
CharacterData.prototype.replaceData = function(offset, count, arg) {};
/**
* @param {number} offset
* @param {number} count
* @return {string}
* @nosideeffects
*/
CharacterData.prototype.substringData = function(offset, count) {};
/**
* @constructor
* @extends {Node}
*/
function Attr() {}
/**
* @type {string}
*/
Attr.prototype.name;
/**
* @type {boolean}
*/
Attr.prototype.specified;
/**
* @type {string}
*/
Attr.prototype.value;
/**
* @constructor
* @extends {Node}
*/
function Element() {}
/**
* @type {string}
*/
Element.prototype.tagName;
/**
* @param {string} name
* @param {number?=} opt_flags
* @return {string}
* @nosideeffects
*/
Element.prototype.getAttribute = function(name, opt_flags) {};
/**
* @param {string} name
* @return {Attr}
* @nosideeffects
*/
Element.prototype.getAttributeNode = function(name) {};
/**
* @param {string} tagname
* @return {!NodeList}
* @nosideeffects
*/
Element.prototype.getElementsByTagName = function(tagname) {};
/**
* @param {string} name
* @return {undefined}
*/
Element.prototype.removeAttribute = function(name) {};
/**
* @param {Attr} oldAttr
* @return {?Attr}
*/
Element.prototype.removeAttributeNode = function(oldAttr) {};
/**
* @param {string} name
* @param {string|number|boolean} value Values are converted to strings with
* ToString, so we accept number and boolean since both convert easily to
* strings.
* @return {undefined}
*/
Element.prototype.setAttribute = function(name, value) {};
/**
* @param {Attr} newAttr
* @return {?Attr}
*/
Element.prototype.setAttributeNode = function(newAttr) {};
// Event handlers
// The DOM level 3 spec has a good index of these
/** @type {?function (Event)} */ Element.prototype.onabort;
/** @type {?function (Event)} */ Element.prototype.onbeforeinput;
/** @type {?function (Event)} */ Element.prototype.onbeforeunload;
/** @type {?function (Event)} */ Element.prototype.onblur;
/** @type {?function (Event)} */ Element.prototype.onchange;
/** @type {?function (Event)} */ Element.prototype.onclick;
/** @type {?function (Event)} */ Element.prototype.oncompositionstart;
/** @type {?function (Event)} */ Element.prototype.oncompositionupdate;
/** @type {?function (Event)} */ Element.prototype.oncompositionend;
/** @type {?function (Event)} */ Element.prototype.oncontextmenu;
/** @type {?function (Event)} */ Element.prototype.oncopy;
/** @type {?function (Event)} */ Element.prototype.oncut;
/** @type {?function (Event)} */ Element.prototype.ondblclick;
/** @type {?function (Event)} */ Element.prototype.onerror;
/** @type {?function (Event)} */ Element.prototype.onfocus;
/** @type {?function (Event)} */ Element.prototype.onfocusin;
/** @type {?function (Event)} */ Element.prototype.onfocusout;
/** @type {?function (Event)} */ Element.prototype.oninput;
/** @type {?function (Event)} */ Element.prototype.onkeydown;
/** @type {?function (Event)} */ Element.prototype.onkeypress;
/** @type {?function (Event)} */ Element.prototype.onkeyup;
/** @type {?function (Event)} */ Element.prototype.onload;
/** @type {?function (Event)} */ Element.prototype.onunload;
/** @type {?function (Event)} */ Element.prototype.onmousedown;
/** @type {?function (Event)} */ Element.prototype.onmousemove;
/** @type {?function (Event)} */ Element.prototype.onmouseout;
/** @type {?function (Event)} */ Element.prototype.onmouseover;
/** @type {?function (Event)} */ Element.prototype.onmouseup;
/** @type {?function (Event)} */ Element.prototype.onmousewheel;
/** @type {?function (Event)} */ Element.prototype.onpaste;
/** @type {?function (Event)} */ Element.prototype.onreset;
/** @type {?function (Event)} */ Element.prototype.onresize;
/** @type {?function (Event)} */ Element.prototype.onscroll;
/** @type {?function (Event)} */ Element.prototype.onselect;
/** @type {?function (Event=)} */ Element.prototype.onsubmit;
/** @type {?function (Event)} */ Element.prototype.ontextinput;
/** @type {?function (Event)} */ Element.prototype.onwheel;
/**
* @constructor
* @extends {CharacterData}
*/
function Text() {}
/**
* @param {number} offset
* @return {Text}
*/
Text.prototype.splitText = function(offset) {};
/**
* @constructor
* @extends {CharacterData}
*/
function Comment() {}
/**
* @constructor
* @extends {Text}
*/
function CDATASection() {}
/**
* @constructor
* @extends {Node}
*/
function DocumentType() {}
/**
* @type {NamedNodeMap}
*/
DocumentType.prototype.entities;
/**
* @type {string}
*/
DocumentType.prototype.name;
/**
* @type {NamedNodeMap}
*/
DocumentType.prototype.notations;
/**
* @constructor
* @extends {Node}
*/
function Notation() {}
/**
* @type {string}
*/
Notation.prototype.publicId;
/**
* @type {string}
*/
Notation.prototype.systemId;
/**
* @constructor
* @extends {Node}
*/
function Entity() {}
/**
* @type {string}
*/
Entity.prototype.publicId;
/**
* @type {string}
*/
Entity.prototype.systemId;
/**
* @type {string}
*/
Entity.prototype.notationName;
/**
* @constructor
* @extends {Node}
*/
function EntityReference() {}
/**
* @constructor
* @extends {Node}
*/
function ProcessingInstruction() {}
/**
* @type {string}
*/
ProcessingInstruction.prototype.data;
/**
* @type {string}
*/
ProcessingInstruction.prototype.target;
/**
* @constructor
* @implements {EventTarget}
*/
function Window() {}
Window.prototype.Window;
/**
* @param {boolean=} opt_useCapture
* @override
*/
Window.prototype.addEventListener = function(type, listener, opt_useCapture) {};
/**
* @param {boolean=} opt_useCapture
* @override
*/
Window.prototype.removeEventListener = function(type, listener, opt_useCapture)
{};
/** @override */
Window.prototype.dispatchEvent = function(evt) {};
/** @type {?function (Event)} */ Window.prototype.onabort;
/** @type {?function (Event)} */ Window.prototype.onbeforeunload;
/** @type {?function (Event)} */ Window.prototype.onblur;
/** @type {?function (Event)} */ Window.prototype.onchange;
/** @type {?function (Event)} */ Window.prototype.onclick;
/** @type {?function (Event)} */ Window.prototype.onclose;
/** @type {?function (Event)} */ Window.prototype.oncontextmenu;
/** @type {?function (Event)} */ Window.prototype.ondblclick;
/** @type {?function (Event)} */ Window.prototype.ondragdrop;
// onerror has a special signature.
/** @type {?function (string, string, number)} */
Window.prototype.onerror;
/** @type {?function (Event)} */ Window.prototype.onfocus;
/** @type {?function (Event)} */ Window.prototype.onhashchange;
/** @type {?function (Event)} */ Window.prototype.onkeydown;
/** @type {?function (Event)} */ Window.prototype.onkeypress;
/** @type {?function (Event)} */ Window.prototype.onkeyup;
/** @type {?function (Event)} */ Window.prototype.onload;
/** @type {?function (Event)} */ Window.prototype.onmousedown;
/** @type {?function (Event)} */ Window.prototype.onmousemove;
/** @type {?function (Event)} */ Window.prototype.onmouseout;
/** @type {?function (Event)} */ Window.prototype.onmouseover;
/** @type {?function (Event)} */ Window.prototype.onmouseup;
/** @type {?function (Event)} */ Window.prototype.onmousewheel;
/** @type {?function (Event)} */ Window.prototype.onpaint;
/** @type {?function (Event)} */ Window.prototype.onpopstate;
/** @type {?function (Event)} */ Window.prototype.onreset;
/** @type {?function (Event)} */ Window.prototype.onresize;
/** @type {?function (Event)} */ Window.prototype.onscroll;
/** @type {?function (Event)} */ Window.prototype.onselect;
/** @type {?function (Event=)} */ Window.prototype.onsubmit;
/** @type {?function (Event)} */ Window.prototype.onunload;
/** @type {?function (Event)} */ Window.prototype.onwheel;