dom.ts

view source

Declarations
#

6 declarations

handle_target_value
#

dom.ts view source

(cb: (value: any, event: any) => void, swallow_event?: boolean): (e: any) => void import {handle_target_value} from '@fuzdev/fuz_util/dom.js';

Handles the value of an event's target and invokes a callback. Defaults to swallowing the event to prevent default actions and propagation.

cb

type (value: any, event: any) => void

swallow_event

type boolean
default true

returns

(e: any) => void

mutates

  • event — calls `swallow()` which mutates the event if `swallow_event` is true

inside_editable
#

dom.ts view source

(el: Element): boolean import {inside_editable} from '@fuzdev/fuz_util/dom.js';

Returns true if the element is within a contenteditable ancestor.

el

type Element

returns

boolean

is_editable
#

dom.ts view source

(el: any): boolean import {is_editable} from '@fuzdev/fuz_util/dom.js';

Checks if the given element is editable. Returns true for text-based input types, textareas, and contenteditable elements.

el

type any

returns

boolean

is_iframed
#

dom.ts view source

(): boolean import {is_iframed} from '@fuzdev/fuz_util/dom.js';

Returns a boolean indicating if the current browser window, if any, is iframed inside of another.

returns

boolean

is_interactive
#

dom.ts view source

(el: any): boolean import {is_interactive} from '@fuzdev/fuz_util/dom.js';

Checks if the element is interactive (clickable, focusable, or otherwise accepts user input). Returns true for buttons, links, form controls, and elements with interactive attributes and ARIA roles.

el

type any

returns

boolean

swallow
#

dom.ts view source

<T extends Pick<Event, "preventDefault" | "stopPropagation" | "stopImmediatePropagation">>(event: T, immediate?: boolean, preventDefault?: boolean): T import {swallow} from '@fuzdev/fuz_util/dom.js';

Stops an event from bubbling and doing default behavior.

event

type T

immediate

defaults to true to use stopImmediatePropagation over stopPropagation

type boolean
default true

preventDefault

defaults to true

type boolean
default true

returns

T

generics

swallow<T extends Pick<Event, 'preventDefault' | 'stopPropagation' | 'stopImmediatePropagation'>>
T
constraint Pick<Event, 'preventDefault' | 'stopPropagation' | 'stopImmediatePropagation'>

mutates

  • event — calls `preventDefault()`, `stopPropagation()`, or `stopImmediatePropagation()`