Function bind

Binds source to one or more element(s). One or more bindings for the same source can be provided.

bind(source, 
// Binds .name field of source values to textContent of #some-element
{ query: `#some-element`, sourceField: `name` },
{ query: `section`, }
);

Can update

  • CSS variables
  • CSS styles
  • textContent / innerHTML
  • HTML DOM attributes and object fields

Can use a particular field on source values, or use the whole value. These can pass through transformValue or transform respectively.

Returns a function to unbind from source and optionally remove HTML element

const unbind = bind( . . . );
unbind(); // Unbind
unbind(true); // Unbind and remove HTML element(s)