Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/evt/lib/index.ts>dom.Element

💧EventEmitter's typesafe replacement
Go to Latest
import { type dom } from "https://deno.land/x/evt@v2.4.16/lib/index.ts";
const { Element } = dom;

Element is the most general base class from which all objects in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element.

Properties

readonly
assignedSlot: HTMLSlotElement | null
readonly
attributes: NamedNodeMap
readonly
classList: DOMTokenList

Allows for manipulation of element's class content attribute as a set of whitespace-separated tokens through a DOMTokenList object.

className: string

Returns the value of element's class content attribute. Can be set to change it.

readonly
clientHeight: number
readonly
clientLeft: number
readonly
clientTop: number
readonly
clientWidth: number
id: string

Returns the value of element's id content attribute. Can be set to change it.

readonly
localName: string

Returns the local name.

readonly
namespaceURI: string | null

Returns the namespace.

onfullscreenchange: ((this: Element, ev: Event) => any) | null
onfullscreenerror: ((this: Element, ev: Event) => any) | null
outerHTML: string
readonly
prefix: string | null

Returns the namespace prefix.

readonly
scrollHeight: number
scrollLeft: number
scrollTop: number
readonly
scrollWidth: number
readonly
shadowRoot: ShadowRoot | null

Returns element's shadow root, if any, and if shadow root's mode is "open", and null otherwise.

slot: string

Returns the value of element's slot content attribute. Can be set to change it.

readonly
tagName: string

Returns the HTML-uppercased qualified name.

Methods

attachShadow(init: ShadowRootInit): ShadowRoot

Creates a shadow root for element and returns it.

closest<K extends keyof HTMLElementTagNameMap>(selector: K): HTMLElementTagNameMap[K] | null

Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise.

closest<K extends keyof SVGElementTagNameMap>(selector: K): SVGElementTagNameMap[K] | null
closest<E extends Element = Element>(selector: string): E | null
getAttribute(qualifiedName: string): string | null

Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise.

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

Returns element's attribute whose namespace is namespace and local name is localName, and null if there is no such attribute otherwise.

getAttributeNames(): string[]

Returns the qualified names of all element's attributes. Can contain duplicates.

getAttributeNode(name: string): Attr | null
getAttributeNodeNS(namespaceURI: string, localName: string): Attr | null
getBoundingClientRect(): DOMRect
getClientRects(): DOMRectList
getElementsByClassName(classNames: string): HTMLCollectionOf<Element>

Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes.

getElementsByTagName<K extends keyof HTMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>
getElementsByTagName<K extends keyof SVGElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>
getElementsByTagName(qualifiedName: string): HTMLCollectionOf<Element>
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>
getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf<Element>
hasAttribute(qualifiedName: string): boolean

Returns true if element has an attribute whose qualified name is qualifiedName, and false otherwise.

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

Returns true if element has an attribute whose namespace is namespace and local name is localName.

hasAttributes(): boolean

Returns true if element has attributes, and false otherwise.

hasPointerCapture(pointerId: number): boolean
insertAdjacentElement(position: InsertPosition, insertedElement: Element): Element | null
insertAdjacentHTML(where: InsertPosition, html: string): void
insertAdjacentText(where: InsertPosition, text: string): void
matches(selectors: string): boolean

Returns true if matching selectors against element's root yields element, and false otherwise.

msGetRegionContent(): any
releasePointerCapture(pointerId: number): void
removeAttribute(qualifiedName: string): void

Removes element's first attribute whose qualified name is qualifiedName.

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

Removes element's attribute whose namespace is namespace and local name is localName.

removeAttributeNode(attr: Attr): Attr
requestFullscreen(options?: FullscreenOptions): Promise<void>

Displays element fullscreen and resolves promise when done.

When supplied, options's navigationUI member indicates whether showing navigation UI while in fullscreen is preferred or not. If set to "show", navigation simplicity is preferred over screen space, and if set to "hide", more screen space is preferred. User agents are always free to honor user preference over the application's. The default value "auto" indicates no application preference.

requestPointerLock(): void
scroll(options?: ScrollToOptions): void
scroll(x: number, y: number): void
scrollBy(options?: ScrollToOptions): void
scrollBy(x: number, y: number): void
scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void
scrollTo(options?: ScrollToOptions): void
scrollTo(x: number, y: number): void
setAttribute(qualifiedName: string, value: string): void

Sets the value of element's first attribute whose qualified name is qualifiedName to value.

setAttributeNS(
namespace: string | null,
qualifiedName: string,
value: string,
): void

Sets the value of element's attribute whose namespace is namespace and local name is localName to value.

setAttributeNode(attr: Attr): Attr | null
setAttributeNodeNS(attr: Attr): Attr | null
setPointerCapture(pointerId: number): void
toggleAttribute(qualifiedName: string, force?: boolean): boolean

If force is not given, "toggles" qualifiedName, removing it if it is present and adding it if it is not present. If force is true, adds qualifiedName. If force is false, removes qualifiedName.

Returns true if qualifiedName is now present, and false otherwise.

webkitMatchesSelector(selectors: string): boolean
addEventListener<K extends keyof ElementEventMap>(
type: K,
listener: (this: Element, ev: ElementEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
removeEventListener<K extends keyof ElementEventMap>(
type: K,
listener: (this: Element, ev: ElementEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void