Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/gauntlet/imports/happy_dom.ts>Element

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

Element.

Properties

_attributes: { [k: string]: Attr; }
readonly
attributes: { [k: string]: Attr | number; }

Returns attributes.

readonly
childElementCount: number

Last element child.

readonly
classList: ClassList
className: string

Returns class name.

readonly
firstElementChild: IElement

First element child.

id: string

Returns ID.

innerHTML: string

Returns inner HTML.

readonly
lastElementChild: IElement

Last element child.

readonly
localName: string

Local name.

readonly
namespaceURI: string
readonly
nextElementSibling: IElement

Next element sibling.

readonly
nodeName: string

Node name.

nodeType: number
outerHTML: string

Returns outer HTML.

readonly
previousElementSibling: IElement

Previous element sibling.

scrollLeft: number
scrollTop: number
shadowRoot: IShadowRoot
tagName: string
textContent: string

Get text value of children.

Methods

protected
_getAttributeName(name: any): string

Returns attribute name.

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

Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just after this ChildNode. DOMString objects are inserted as equivalent Text nodes.

append(...nodes: (string | INode)[]): 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.

attachShadow(shadowRootInit: { mode: string; }): IShadowRoot

Attaches a shadow root.

optional
attributeChangedCallback(
name: string,
oldValue: string,
newValue: string,
): void

Attribute changed callback.

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

Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just before this ChildNode. DOMString objects are inserted as equivalent Text nodes.

cloneNode(deep?: boolean): IElement

Clones a node.

Returns a range.

getAttribute(name: string): string

Returns attribute value.

getAttributeNode(name: string): Attr

Returns an Attr node.

getAttributeNodeNS(namespace: string, name: string): Attr

Returns a namespaced Attr node.

getAttributeNS(namespace: string, localName: string): string

Returns namespace attribute value.

Returns the size of an element and its position relative to the viewport.

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.

hasAttribute(name: string): boolean

Returns a boolean value indicating whether the specified element has the attribute or not.

hasAttributeNS(namespace: string, localName: string): boolean

Returns a boolean value indicating whether the specified element has the namespace attribute or not.

hasAttributes(): boolean

Returns "true" if the element has attributes.

insertAdjacentElement(position: TInsertAdjacentPositions, element: INode): INode | null

Inserts a node to the given position.

insertAdjacentHTML(position: TInsertAdjacentPositions, text: string): void

Inserts an HTML string to the given position.

insertAdjacentText(position: TInsertAdjacentPositions, text: string): void

Inserts text to the given position.

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

Inserts a node before another.

matches(selector: string): boolean

The matches() method checks to see if the Element would be selected by the provided selectorString.

prepend(...nodes: (string | INode)[]): 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 matching node.

querySelectorAll(selector: string): INodeList<IElement>

Query CSS selector to find matching nodes.

remove(): void

Removes the node from its parent.

removeAttribute(name: string): void

Removes an attribute.

removeAttributeNode(attribute: Attr): void

Removes an Attr node.

removeAttributeNodeNS(attribute: Attr): void

Removes an Attr node.

removeAttributeNS(namespace: string, localName: string): void

Removes a namespace attribute.

Remove Child element from childNodes array.

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

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

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

The Node.replaceWith() method replaces this Node in the children list of its parent with a set of Node or DOMString objects.

scroll(x: { top?: number; left?: number; behavior?: string; } | number, y?: number): void

Scrolls to a particular set of coordinates.

scrollTo(x: { top?: number; left?: number; behavior?: string; } | number, y?: number): void

Scrolls to a particular set of coordinates.

setAttribute(name: string, value: string): void

Sets an attribute.

setAttributeNode(attribute: Attr): Attr

The setAttributeNode() method adds a new Attr node to the specified element.

setAttributeNodeNS(attribute: Attr): Attr

The setAttributeNodeNS() method adds a new Attr node to the specified element.

setAttributeNS(
namespaceURI: string,
name: string,
value: string,
): void

Sets a namespace attribute.

toString(): string

Converts to string.

Static Properties

_observedAttributes: string[]
observedAttributes: string[]