This is a prerelease version of FAST (3.0.0-rc.1).

@microsoft/fast-element > HTMLBindingDirective

HTMLBindingDirective class

The central binding directive that bridges data expressions and DOM updates.

HTMLBindingDirective fulfills three roles simultaneously: - **HTMLDirective**: Produces placeholder HTML via createHTML() during template authoring. - **ViewBehaviorFactory**: Creates behaviors (returns itself) during view creation. - **ViewBehavior / EventListener**: Attaches to a DOM node during bind, manages expression observers for reactive updates, and handles DOM events directly.

The aspectType (set by HTMLDirective.assignAspect during template processing) determines which DOM "sink" function is used to apply values — e.g., setAttribute for attributes, addEventListener for events, textContent for content.

Signature:

export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected, BindingDirective

Implements: HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected, BindingDirective

Constructors

Constructor

Modifiers

Description

(constructor)(dataBinding)

Creates an instance of HTMLBindingDirective.

Properties

Property

Modifiers

Type

Description

aspectType

DOMAspect

The type of aspect to target.

dataBinding

Binding

id

string

The unique id of the factory.

policy

DOMPolicy

The policy that the created behavior must run under.

sourceAspect

string

The original source aspect exactly as represented in markup.

targetAspect

string

The evaluated target aspect, determined after processing the source.

targetNodeId

string

The structural id of the DOM node to which the created behavior will apply.

targetTagName

string | null

The tagname associated with the target node.

Methods

Method

Modifiers

Description

createBehavior()

Creates a behavior.

createHTML(add)

Creates HTML to be used within a template.