bindProps

Commons
stable

Imperatively apply a props record to a DOM element: event handlers (onXxx keys) are attached via addEventListener with deduplication, attribute keys are set or removed via setAttribute / removeAttribute.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

el
required
HTMLElement
The target DOM element to receive the props.
props
required
Record<string, any>
Object of prop key-value pairs. Keys starting with "on" are treated as event listeners; others are set as attributes. A null/undefined value removes the attribute or the listener.

API

Return value

The value returned by this util.

No return value. Mutations are applied directly to the element.

Usage

Examples

Ready-to-paste usage snippets.

Apply attributes and listeners to a custom element

typescript