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

x/ink/tsdom/tsdom.ts>HTMLElement

Terminal string color for Deno
Latest
class HTMLElement
extends Node
import { HTMLElement } from "https://deno.land/x/ink@1.3/tsdom/tsdom.ts";

HTMLElement, which contains a set of children.

Note: this is a minimalist implementation, no complete tree structure provided (no parentNode, nextSibling, previousSibling etc).

Constructors

new
HTMLElement(
tagName: string,
keyAttrs: KeyAttributes,
rawAttrs?,
parentNode?,
)

Creates an instance of HTMLElement.

Properties

private
_attrs: Attributes
private
_rawAttrs: RawAttributes
readonly
attributes

Get attributes

classNames
readonly
firstChild

Get first child node

id: string
readonly
innerHTML
readonly
lastChild

Get last child node

nodeType

Node Type declaration.

readonly
outerHTML
readonly
rawAttributes

Get escaped (as-it) attributes

readonly
rawText

Get escpaed (as-it) text value of current node and its children.

readonly
structure

Get DOM structure

readonly
structuredText

Get structured Text (with '\n' etc.)

readonly
text

Get unescaped text value of current node and its children.

Methods

appendChild<T extends Node = Node>(node: T)

Append a child node to childNodes

exchangeChild(oldNode: Node, newNode: Node)

Exchanges given child with new child

querySelector(selector: string | Matcher)

Query CSS Selector to find matching node.

querySelectorAll(selector: string | Matcher)

Query CSS selector to find matching nodes.

Remove Child element from childNodes array

Remove whitespaces in this sub tree.

set_content(content: string | Node | Node[])
trimRight(pattern: RegExp)

Trim element from right (in block) after seeing pattern in a TextNode.