Mixins / Inside-out composition
How the resolver prevents attachment conflicts
Instead of concatenating attributes in render order, the resolver enforces clear ownership rules:
- Classes: Merged additively and deduplicated.
- Inline styles: Merged per CSS property.
- Events and scalar attributes: Single owner per slot; a second handler emits a diagnostic instead of silently overwriting.
- Structural keys:
KeyandInnerHTMLstay protected from overrides. - Mounts: Multiple mounts on one slot compose into a single
OnMount.
For keyboard events (keydown), widgets and callers compose through named routes in Behaviors.Keys. A widget exposes a routes option so callers add key bindings cleanly; colliding chords throw mixins:key-conflict unless resolved explicitly with Keys.first. See Keys: one owner for a slot's keydown.
Capabilities, permissions, and protected slots
Every Slot declaration captures:
- A hierarchical Capability (
TextInputsatisfies a requirement forInteractive). - Published Event and Attr tokens.
- Platform Requirement tokens (Keyboard, Pointer, Clipboard).
- Whether the slot is
hiddenfrom external callers or marks specific events/attributesprotected.
Use .make constructors to define custom capabilities, events, and attributes when needed.
Composing Slots with foldkit-surface
Surface and Slots govern orthogonal boundaries: Surface restricts which Model fields a feature reads and which Message variants it emits, while Slots defines which DOM points callers may customize.
Diagram source
flowchart LR
app["Application<br/>Model · Message · update"]
surface["Surface<br/>observe / emit boundary"]
view["SlotView<br/>structural extension points"]
attachments["Style + Behavior"]
app --> surface --> view
attachments --> viewfoldkit-mixins-surface bridges both so a SlotView receives a typed Projection and narrowed Message builder without requiring Surface to use foldkit-mixins elsewhere.