Overview
$(target) returns a DollarChain — every method returns this so you can chain attribute, style, class, text, event, ARIA, and measurement helpers.
Accepts a raw Element, a MatesRef, or a CSS selector string (document.querySelector, first match). When a ref’s .value is still undefined, or a selector matches nothing, $ throws. Use selectors / refs after mount — onMount / onPaint / onUpdate / Raw setup().
eleHook mounts receive the same $ bound to the host element — see eleHook.
$ vs directives vs refs
|
API
|
When
|
Notes
|
|---|---|---|
$(el)
| Imperative | Lifecycle callbacks, third-party widgets, one-off DOM ops. |
attr / style / classes
| Declarative |
Prefer element directives inside html`…` when values are reactive.
|
ref + setRef
| Handle |
Grab the node, then call $ after mount.
|
Chain attr · style · classes · on · text
On mount, $() configures the box and toggles a class on click — no reactive template bindings required for those DOM ops.
measure() bounding rect
measure(cb) reads getBoundingClientRect synchronously and keeps the chain alive for further calls.