To initialize a behavior its dependecies have to be injected first,then the binding to its value has to be processed and finally thedefined bindings have to be set up.
This has to be done for all definitions along the prototype chain to makesure inherited features don't break.
The actual string literal of the attribute used for the current behavior instance.
The element the behavior was attached to.
This static property lets you define listeners that will be executed whenproperties of the behavior change.
It should be a map where the keys are paths that should be watched on the behavior instanceand the values are names of methods that will be invoked on it when the valueat a path changes.
The following example shows a behavior that reacts to a change in the height ofthe defining element.
export default class MyBehavior extends Behavior { static inject: {element: Element}; static bindings = { 'element.clientHeight': 'heightChange' }; width: number; heightChange(height: number) { this.width = height * 2; }}
Updates the class list of the element.
The Classes behavior can be used to automatically add classes to anelement or remove them based on some truth value. The value shouldbe an expression that results to an object where the keys are therelevant class names and their values any valid Expression.
Example
This simple example adds the bold class to an h1 element whenever thevalue of isBold in the local scope is truthy.
<h1 classes="{bold: isBold}">Mahalo</h1>
{ default } from mahalo/behaviors/classes