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: Key and InnerHTML stay 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 (TextInput satisfies a requirement for Interactive).
  • Published Event and Attr tokens.
  • Platform Requirement tokens (Keyboard, Pointer, Clipboard).
  • Whether the slot is hidden from external callers or marks specific events/attributes protected.

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.

ApplicationModel · Message · updateSurfaceobserve / emit boundarySlotViewstructural extension pointsStyle + Behavior
Diagram source
mermaid
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 --> view

foldkit-mixins-surface bridges both so a SlotView receives a typed Projection and narrowed Message builder without requiring Surface to use foldkit-mixins elsewhere.