GitHub v1.3.1

attributes

Stable

Declares, coerces, and validates host HTML attributes into reactive component state.

TypeScript Signature

typescript
Code copied!
  export const attributes: Record<string, { type: stringconstructor | numberconstructor booleanconstructor; default?: any; required?: boolean; reflect?: transform?: (val: any)> any;
    validate?: (val: any) => boolean | string;
  }>
          </string,>

The 6-Step Execution Pipeline

Deterministic transformation sequence executed upon every attribute mount or host mutation.

01
Required Check

Validates presence.

02
Coerce

Casts raw string to primitive.

03
Transform

Executes custom transform callback.

04
Values Check

Inspects permissible enumerations.

05
Validate

Evaluates user validation predicate.

06
State Application

Injects reactive signal into host.

CORALITE-E102: Mutex Violation

required: true cannot be combined with a default assignment.

Allowed Types

TypeCoercion BehaviorReflection Behavior
StringCasts to string.No (unless reflect: true).
NumberParses float.No (unless reflect: true).
BooleanPresence is true.Yes. Renders as attr="".

Forbidden vs. Required

javascript
Code copied!
  attributes: {
    user: { type: Object }
  }
javascript
Code copied!
  attributes: {
    userId: { type: String }
  }