happy-dom
Version:
Happy DOM is a JavaScript implementation of a web browser without its graphical user interface. It includes many web standards from WHATWG DOM and HTML.
320 lines • 9.52 kB
TypeScript
import EventTarget from '../../event/EventTarget.cjs';
import * as PropertySymbol from '../../PropertySymbol.cjs';
import MutationListener from '../../mutation-observer/MutationListener.cjs';
import Document from '../document/Document.cjs';
import Element from '../element/Element.cjs';
import NodeTypeEnum from './NodeTypeEnum.cjs';
import NodeDocumentPositionEnum from './NodeDocumentPositionEnum.cjs';
import NodeList from './NodeList.cjs';
/**
* Node.
*/
export default class Node extends EventTarget {
static [PropertySymbol.ownerDocument]: Document | null;
static readonly ELEMENT_NODE = NodeTypeEnum.elementNode;
static readonly ATTRIBUTE_NODE = NodeTypeEnum.attributeNode;
static readonly TEXT_NODE = NodeTypeEnum.textNode;
static readonly CDATA_SECTION_NODE = NodeTypeEnum.cdataSectionNode;
static readonly COMMENT_NODE = NodeTypeEnum.commentNode;
static readonly DOCUMENT_NODE = NodeTypeEnum.documentNode;
static readonly DOCUMENT_TYPE_NODE = NodeTypeEnum.documentTypeNode;
static readonly DOCUMENT_FRAGMENT_NODE = NodeTypeEnum.documentFragmentNode;
static readonly PROCESSING_INSTRUCTION_NODE = NodeTypeEnum.processingInstructionNode;
static readonly DOCUMENT_POSITION_CONTAINED_BY = NodeDocumentPositionEnum.containedBy;
static readonly DOCUMENT_POSITION_CONTAINS = NodeDocumentPositionEnum.contains;
static readonly DOCUMENT_POSITION_DISCONNECTED = NodeDocumentPositionEnum.disconnect;
static readonly DOCUMENT_POSITION_FOLLOWING = NodeDocumentPositionEnum.following;
static readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = NodeDocumentPositionEnum.implementationSpecific;
static readonly DOCUMENT_POSITION_PRECEDING = NodeDocumentPositionEnum.preceding;
readonly ELEMENT_NODE: any;
readonly ATTRIBUTE_NODE: any;
readonly TEXT_NODE: any;
readonly CDATA_SECTION_NODE: any;
readonly COMMENT_NODE: any;
readonly DOCUMENT_NODE: any;
readonly DOCUMENT_TYPE_NODE: any;
readonly DOCUMENT_FRAGMENT_NODE: any;
readonly PROCESSING_INSTRUCTION_NODE: any;
readonly DOCUMENT_POSITION_CONTAINED_BY: any;
readonly DOCUMENT_POSITION_CONTAINS: any;
readonly DOCUMENT_POSITION_DISCONNECTED: any;
readonly DOCUMENT_POSITION_FOLLOWING: any;
readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: any;
readonly DOCUMENT_POSITION_PRECEDING: any;
[PropertySymbol.isConnected]: boolean;
[PropertySymbol.ownerDocument]: Document;
[PropertySymbol.parentNode]: Node | null;
[PropertySymbol.nodeType]: NodeTypeEnum;
[PropertySymbol.rootNode]: Node;
[PropertySymbol.formNode]: Node;
[PropertySymbol.selectNode]: Node;
[PropertySymbol.textAreaNode]: Node;
[PropertySymbol.observers]: MutationListener[];
[PropertySymbol.childNodes]: NodeList<Node>;
/**
* Constructor.
*/
constructor();
/**
* Returns `Symbol.toStringTag`.
*
* @returns `Symbol.toStringTag`.
*/
get [Symbol.toStringTag](): string;
/**
* Returns connected state.
*
* @returns Connected state.
*/
get isConnected(): boolean;
/**
* Returns owner document.
*
* @returns Owner document.
*/
get ownerDocument(): Document;
/**
* Returns parent node.
*
* @returns Parent node.
*/
get parentNode(): Node | null;
/**
* Returns node type.
*
* @returns Node type.
*/
get nodeType(): number;
/**
* Get child nodes.
*
* @returns Child nodes list.
*/
get childNodes(): NodeList<Node>;
/**
* Get text value of children.
*
* @returns Text content.
*/
get textContent(): string;
/**
* Sets text content.
*
* @param _textContent Text content.
*/
set textContent(_textContent: string);
/**
* Node value.
*
* @returns Node value.
*/
get nodeValue(): string;
/**
* Sets node value.
*/
set nodeValue(_nodeValue: string);
/**
* Node name.
*
* @returns Node name.
*/
get nodeName(): string;
/**
* Previous sibling.
*
* @returns Node.
*/
get previousSibling(): Node;
/**
* Next sibling.
*
* @returns Node.
*/
get nextSibling(): Node;
/**
* First child.
*
* @returns Node.
*/
get firstChild(): Node;
/**
* Last child.
*
* @returns Node.
*/
get lastChild(): Node;
/**
* Returns parent element.
*
* @returns Element.
*/
get parentElement(): Element | null;
/**
* Returns base URI.
*
* @returns Base URI.
*/
get baseURI(): string;
/**
* Connected callback.
*/
connectedCallback?(): void;
/**
* Disconnected callback.
*/
disconnectedCallback?(): void;
/**
* Returns "true" if the node has child nodes.
*
* @returns "true" if the node has child nodes.
*/
hasChildNodes(): boolean;
/**
* Returns "true" if this node contains the other node.
*
* @param otherNode Node to test with.
* @returns "true" if this node contains the other node.
*/
contains(otherNode: Node): boolean;
/**
* Returns closest root node (Document or ShadowRoot).
*
* @param options Options.
* @param options.composed A Boolean that indicates whether the shadow root should be returned (false, the default), or a root node beyond shadow root (true).
* @returns Node.
*/
getRootNode(options?: {
composed: boolean;
}): Node;
/**
* Clones a node.
*
* @param [deep=false] "true" to clone deep.
* @returns Cloned node.
*/
cloneNode(deep?: boolean): Node;
/**
* Append a child node to childNodes.
*
* @param node Node to append.
* @returns Appended node.
*/
appendChild(node: Node): Node;
/**
* Remove Child element from childNodes array.
*
* @param node Node to remove.
* @returns Removed node.
*/
removeChild(node: Node): Node;
/**
* Inserts a node before another.
*
* @param newNode Node to insert.
* @param referenceNode Node to insert before.
* @returns Inserted node.
*/
insertBefore(newNode: Node, referenceNode: Node | null): Node;
/**
* Replaces a node with another.
*
* @param newChild New child.
* @param oldChild Old child.
* @returns Replaced node.
*/
replaceChild(newChild: Node, oldChild: Node): Node;
/**
* Clones a node.
*
* @param [deep=false] "true" to clone deep.
* @returns Cloned node.
*/
[PropertySymbol.cloneNode](deep?: boolean): Node;
/**
* Append a child node to childNodes.
*
* @param node Node to append.
* @returns Appended node.
*/
[PropertySymbol.appendChild](node: Node): Node;
/**
* Remove Child element from childNodes array.
*
* @param node Node to remove.
* @returns Removed node.
*/
[PropertySymbol.removeChild](node: Node): Node;
/**
* Inserts a node before another.
*
* @param newNode Node to insert.
* @param referenceNode Node to insert before.
* @returns Inserted node.
*/
[PropertySymbol.insertBefore](newNode: Node, referenceNode: Node | null): Node;
/**
* Replaces a node with another.
*
* @param newChild New child.
* @param oldChild Old child.
* @returns Replaced node.
*/
[PropertySymbol.replaceChild](newChild: Node, oldChild: Node): Node;
/**
* Compares two nodes.
* Two nodes are equal if they have the same type, defining the same attributes, and so on.
*
* @param node Node to compare.
* @returns boolean - `true` if two nodes are equal.
*/
isEqualNode(node: Node): boolean;
/**
* Converts the node to a string.
*
* @param listener Listener.
*/
toString(): string;
/**
* Observeres the node.
* Used by MutationObserver, but it is not part of the HTML standard.
*
* @param listener Listener.
*/
[PropertySymbol.observe](listener: MutationListener): void;
/**
* Stops observing the node.
* Used by MutationObserver, but it is not part of the HTML standard.
*
* @param listener Listener.
*/
[PropertySymbol.unobserve](listener: MutationListener): void;
/**
* Connects this element to another element.
*
* @param parentNode Parent node.
*/
[PropertySymbol.connectToNode](parentNode?: Node): void;
/**
* Reports the position of its argument node relative to the node on which it is called.
*
* @see https://dom.spec.whatwg.org/#dom-node-comparedocumentposition
* @param otherNode Other node.
*/
compareDocumentPosition(otherNode: Node): number;
/**
* Normalizes the sub-tree of the node, i.e. joins adjacent text nodes, and
* removes all empty text nodes.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/normalize
*/
normalize(): void;
/**
* Determines whether the given node is equal to the current node.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/isSameNode
* @param node Node to check.
* @returns True if the given node is equal to the current node, otherwise false.
*/
isSameNode(node: Node): boolean;
}
//# sourceMappingURL=Node.d.ts.map