Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/gauntlet/imports/happy_dom.ts>Document

Work-in-progress front-end tool which does put a smile on my face
Latest
class Document
implements IDocument
extends Node
Re-export
import { Document } from "https://deno.land/x/gauntlet@v0.0.9/imports/happy_dom.ts";

Document.

Constructors

new
Document()

Creates an instance of Document.

Properties

private
_defaultView
protected
_isConnected: boolean
protected
_isFirstWrite: boolean
protected
_isFirstWriteAfterOpen: boolean
_readyStateManager: DocumentReadyStateManager
adoptedStyleSheets: CSSStyleSheet[]
readonly
body: IHTMLElement

Returns element.

readonly
childElementCount: number

Last element child.

readonly
children: IHTMLCollection<IElement>
defaultView: Window

Returns default view.

readonly
doctype: IDocumentType

Returns document type element.

readonly
documentElement: IHTMLElement

Returns element.

readonly
firstElementChild: IElement

First element child.

readonly
head: IHTMLElement

Returns element.

implementation: DOMImplementation
readonly
lastElementChild: IElement

Last element child.

readonly
nodeName: string

Node name.

nodeType: number
onreadystatechange: (event: Event) => void
readonly
readyState
readonly
styleSheets: CSSStyleSheet[]

Returns CSS style sheets.

Methods

Adopts a node.

append(...nodes: (INode | string)[]): void

Inserts a set of Node objects or DOMString objects after the last child of the ParentNode. DOMString objects are inserted as equivalent Text nodes.

Append a child node to childNodes.

cloneNode(deep?: boolean): IDocument

Clones a node.

close(): void

Closes the document.

createAttribute(name: string): Attr

Creates an Attr node.

createAttributeNS(namespaceURI: string, qualifiedName: string): Attr

Creates a namespaced Attr node.

createComment(data?: string): ICharacterData

Creates a comment node.

Creates a document fragment.

createElement(tagName: string, options?: { is: string; }): IElement

Creates an element.

createElementNS(
namespaceURI: string,
qualifiedName: string,
options?: { is: string; },
): IElement

Creates an element with the specified namespace URI and qualified name.

createEvent(_type: string): Event

Creates an event.

createTextNode(data?: string): ICharacterData

Creates a text node.

createTreeWalker(
root: INode,
whatToShow?: number,
filter?: INodeFilter,
): TreeWalker

Creates a Tree Walker.

Returns an element by ID.

Returns an elements by class name.

Returns an elements by tag name.

getElementsByTagNameNS(namespaceURI: string, tagName: string): IHTMLCollection<IElement>

Returns an elements by tag name and namespace.

importNode(node: INode, deep?: boolean): INode

Imports a node.

insertBefore(newNode: INode, referenceNode?: INode): INode

Inserts a node before another.

Opens the document.

prepend(...nodes: (INode | string)[]): void

Inserts a set of Node objects or DOMString objects before the first child of the ParentNode. DOMString objects are inserted as equivalent Text nodes.

querySelector(selector: string): IElement

Query CSS Selector to find a matching element.

querySelectorAll(selector: string): INodeList<IElement>

Query CSS selector to find matching elments.

Remove Child element from childNodes array.

replaceChildren(...nodes: (INode | string)[]): void

Replaces the existing children of a node with a specified new set of children.

write(html: string): void

Replaces the document HTML with new HTML.