Liking cljdoc? Tell your friends :D

baredom.utils.dom


define-bool-default-true-prop!cljs

(define-bool-default-true-prop! proto prop-name attr-name)

Install a boolean JS property for an HTML attribute that defaults to true. Absent → true, attribute value "false" (case-insensitive, trimmed) → false, any other value → true. Setter REMOVES the attribute for truthy values (so the explicit-true HTML matches the natural-true absent default) and writes the literal "false" for falsy. Removing for falsy would resolve back to the default true, defeating the point — hence the explicit "false" encoding.

Use for dismissible, arrows, dots, spinner, etc. — boolean attributes whose natural state is enabled and opting out is explicit. This is the centralised form of the Tier-2 pattern previously hand-rolled in x-alert, x-carousel, and x-splash.

Install a boolean JS property for an HTML attribute that defaults to
`true`. Absent → true, attribute value `"false"` (case-insensitive,
trimmed) → false, any other value → true. Setter REMOVES the attribute
for truthy values (so the explicit-true HTML matches the natural-true
absent default) and writes the literal `"false"` for falsy. Removing
for falsy would resolve back to the default `true`, defeating the
point — hence the explicit `"false"` encoding.

Use for `dismissible`, `arrows`, `dots`, `spinner`, etc. — boolean
attributes whose natural state is enabled and opting out is explicit.
This is the centralised form of the Tier-2 pattern previously
hand-rolled in x-alert, x-carousel, and x-splash.
sourceraw docstring

define-bool-prop!cljs

(define-bool-prop! proto prop-name attr-name)

Install a boolean JS property that reflects to/from an HTML attribute.

Install a boolean JS property that reflects to/from an HTML attribute.
sourceraw docstring

define-number-prop!cljs

(define-number-prop! proto prop-name attr-name default-val)

Install a numeric JS property that reflects to/from an HTML attribute. default-val is returned when the attribute is absent or non-numeric.

Install a numeric JS property that reflects to/from an HTML attribute.
`default-val` is returned when the attribute is absent or non-numeric.
sourceraw docstring

define-parsed-prop!cljs

(define-parsed-prop! proto prop-name attr-name parse-fn)

Install a JS property whose getter runs parse-fn on the raw HTML attribute value — so authors who write un-normalised attribute values still see the parsed value through the property.

Setter coerces v to its string form via (str v) and writes the attribute, or removes the attribute when v is nil/undefined.

This replaces ~12 lines of hand-rolled .defineProperty boilerplate per property in components whose getters need to run a parse-fn (Tier-2 components like x-liquid-dock / x-liquid-fill / x-liquid-glass / x-metaball-cursor).

Install a JS property whose getter runs `parse-fn` on the raw HTML
attribute value — so authors who write un-normalised attribute values
still see the *parsed* value through the property.

Setter coerces v to its string form via `(str v)` and writes the
attribute, or removes the attribute when v is nil/undefined.

This replaces ~12 lines of hand-rolled `.defineProperty` boilerplate
per property in components whose getters need to run a parse-fn
(Tier-2 components like x-liquid-dock / x-liquid-fill /
x-liquid-glass / x-metaball-cursor).
sourceraw docstring

define-string-prop!cljs

(define-string-prop! proto prop-name attr-name)
(define-string-prop! proto prop-name attr-name default-val)

Install a string JS property that reflects to/from an HTML attribute. default-val is returned when the attribute is absent (defaults to nil).

Install a string JS property that reflects to/from an HTML attribute.
`default-val` is returned when the attribute is absent (defaults to nil).
sourceraw docstring

dispatch!cljs

(dispatch! el event-name detail)

Dispatch a non-cancelable CustomEvent that bubbles and is composed.

Dispatch a non-cancelable CustomEvent that bubbles and is composed.
sourceraw docstring

dispatch-cancelable!cljs

(dispatch-cancelable! el event-name detail)

Dispatch a cancelable CustomEvent. Returns true when NOT cancelled.

Dispatch a cancelable CustomEvent. Returns true when NOT cancelled.
sourceraw docstring

dispatch-document!cljs

(dispatch-document! event-name)
(dispatch-document! event-name detail)

Dispatch a non-bubbling, non-composed CustomEvent on document. Used for parent notification when the source element is disconnecting and normal bubbling cannot reach the parent. Single-arity omits the detail field entirely (event.detail === null).

Dispatch a non-bubbling, non-composed CustomEvent on document.
Used for parent notification when the source element is disconnecting
and normal bubbling cannot reach the parent.
Single-arity omits the detail field entirely (event.detail === null).
sourceraw docstring

get-attrcljs

(get-attr el attr-name)
source

getvcljs

(getv el k)
source

has-attr?cljs

(has-attr? el attr-name)
source

initialized?cljs

(initialized? el key)
source

install-properties!cljs

(install-properties! proto property-api)

Install JS property accessors on a prototype, driven by a property-api map. Each entry is {prop-key {:type 'boolean|'string|'number :reflects-attribute attr-name :default default-val}}. Skips entries marked :readonly true. For 'number entries, an omitted :default falls back to 0; declare :default explicitly when the natural empty value differs.

Install JS property accessors on a prototype, driven by a property-api map.
Each entry is {prop-key {:type 'boolean|'string|'number
                         :reflects-attribute attr-name
                         :default default-val}}.
Skips entries marked :readonly true. For `'number` entries, an
omitted `:default` falls back to `0`; declare `:default` explicitly
when the natural empty value differs.
sourceraw docstring

mark-initialized!cljs

(mark-initialized! el key)
source

remove-attr!cljs

(remove-attr! el attr-name)
source

remove-attr-untraced!cljs

(remove-attr-untraced! el attr-name)

Like remove-attr! but skips the trace recorder. Use only in animation hot paths — see comment block above.

Like remove-attr! but skips the trace recorder. Use only in animation
hot paths — see comment block above.
sourceraw docstring

set-attr!cljs

(set-attr! el attr-name value)
source

set-attr-untraced!cljs

(set-attr-untraced! el attr-name value)

Like set-attr! but skips the trace recorder. Use only in animation hot paths — see comment block above.

Like set-attr! but skips the trace recorder. Use only in animation
hot paths — see comment block above.
sourceraw docstring

set-bool-attr!cljs

(set-bool-attr! el attr-name value)

Delegates to set-attr!/remove-attr! so a single hook site fires per call.

Delegates to set-attr!/remove-attr! so a single hook site fires per call.
sourceraw docstring

setv!cljs

(setv! el k v)
source

setv-untraced!cljs

(setv-untraced! el k v)

Like setv! but skips the trace recorder. Use for instance-field writes that have no diagnostic value at any frequency — typically the trio of animation bookkeeping fields stamped every frame inside animate!:

k-raf — the requestAnimationFrame id (replaced each frame) k-last-frame — the previous frame's timestamp k-time — accumulated animation time

Tracing these records ~120 state/instance-field-set events per second per running animation, drowning out semantic state changes. Use the normal setv! for actual UI state (selection, hover, pressed, etc.).

Like setv! but skips the trace recorder. Use for instance-field writes
that have no diagnostic value at any frequency — typically the trio
of animation bookkeeping fields stamped every frame inside `animate!`:

  k-raf         — the requestAnimationFrame id (replaced each frame)
  k-last-frame  — the previous frame's timestamp
  k-time        — accumulated animation time

Tracing these records ~120 state/instance-field-set events per second
per running animation, drowning out semantic state changes. Use the
normal `setv!` for actual UI state (selection, hover, pressed, etc.).
sourceraw docstring

trace-hookcljs

Dev-only extension point for dev/x-trace-history. Holds a 1-arg function that receives a CLJS payload describing each mutation or dispatch. Reset via reset!. nil by default — when nil, every site is a single atom-deref + nil check.

Dev-only extension point for dev/x-trace-history. Holds a
1-arg function that receives a CLJS payload describing each
mutation or dispatch. Reset via reset!. nil by default —
when nil, every site is a single atom-deref + nil check.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close