Thin CLJS wrapper over wc-shim.js so you don't touch classes or js*. Provides helpers for attributes, props, shadow DOM, and hot reload support.
Thin CLJS wrapper over wc-shim.js so you don't touch classes or js*. Provides helpers for attributes, props, shadow DOM, and hot reload support.
(attr el k)Get raw attribute from element.
Get raw attribute from element.
(define! tag opts)Define a Custom Element with batched attribute/property updates by default.
New batched API: :attr (fn [el delta] ...) ; delta = {'attr-name' 'new-value' ...} :prop (fn [el delta] ...) ; delta = {'prop-name' new-value ...}
Batching happens automatically using requestAnimationFrame. Multiple rapid changes are collected and delivered as a single delta.
tag - string tag name, e.g. "x-counter" opts - hooks/options map with batched callbacks
Returns the constructor (for completeness), but you rarely need it.
Define a Custom Element with batched attribute/property updates by default.
New batched API:
:attr (fn [el delta] ...) ; delta = {'attr-name' 'new-value' ...}
:prop (fn [el delta] ...) ; delta = {'prop-name' new-value ...}
Batching happens automatically using requestAnimationFrame.
Multiple rapid changes are collected and delivered as a single delta.
tag - string tag name, e.g. "x-counter"
opts - hooks/options map with batched callbacks
Returns the constructor (for completeness), but you rarely need it.(get-initial-attrs el attr-map)Extract initial-only attributes on first render - React compatible.
Reads attributes from the element once (on first call) and parses them using the provided attribute map. Subsequent calls return nil.
This pattern is ideal for 'initial view' parameters that should only be applied once on component initialization, preventing conflicts with user interactions or React re-renders.
Usage: (let [initial (get-initial-attrs el {:view-year js/parseInt :view-month js/parseInt :min-date date/parse-value})] (when (seq initial) (apply-initial-state! el initial)))
Arguments:
Returns:
Extract initial-only attributes on first render - React compatible.
Reads attributes from the element once (on first call) and parses them
using the provided attribute map. Subsequent calls return nil.
This pattern is ideal for 'initial view' parameters that should only
be applied once on component initialization, preventing conflicts
with user interactions or React re-renders.
Usage:
(let [initial (get-initial-attrs el {:view-year js/parseInt
:view-month js/parseInt
:min-date date/parse-value})]
(when (seq initial)
(apply-initial-state! el initial)))
Arguments:
- el: The web component element
- attr-map: Map of attribute keywords to parser functions
Returns:
- Map of parsed attribute values (first call only)
- nil on subsequent calls(get-props el)Return current props as CLJS map.
Return current props as CLJS map.
(parse-bool-attr el k)Boolean attribute semantics: presence -> true, explicit 'false' -> false.
Boolean attribute semantics: presence -> true, explicit 'false' -> false.
(reload-all-components!)Force refresh all registered components after hot reload
Force refresh all registered components after hot reload
(set-props! el m)Batch set props (EDN map). Triggers per-key prop hook.
Batch set props (EDN map). Triggers per-key prop hook.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |