FunctionOptionalelementName: stringThe custom element tag name. Inferred as the kebab-case of
className if omitted (e.g. "MyEl" → "my-el").
Optionaloptions: DefineOptionsConfiguration options. See DefineOptions.
Stage-3 class decorator factory that registers a class in the TurboDom registry and, if the class extends a DOM element, also registers it as a custom HTML element. Specifically, it:
Element:
customElements registry under the provided or inferred tag name.tagName property.create() method to automatically inject the tag name into creation properties.observedAttributes getter aggregating all @observe-decorated fields
across the entire class hierarchy.attributeChangedCallback that mirrors HTML attribute changes to
their corresponding @observe-decorated fields, and vice versa.Functiondefine
The class to register.
OptionalelementName: stringThe custom element tag name. Inferred as the kebab-case of
className if omitted.
OptionalclassName: stringThe class name, used as the registry key. Inferred from
Base.name if omitted.
Optionaloptions: DefineOptionsConfiguration options. See DefineOptions.
The class, unchanged, after all setup has been applied.
Imperative equivalent of the @define decorator. Applies identical registration
and setup logic without requiring decorator syntax — useful for dynamically registering classes
at runtime, or in build environments where class decorators cause unwanted output transformations.
When the class extends a DOM Element, it:
customElements registry.tagName property.create() method to automatically inject the tag.observedAttributes getter across the class hierarchy.attributeChangedCallback attribute bridge.For all classes (element or not), it registers the class in the registry by RegistryCategory.
class MyEl extends TurboElement { ... }
define(MyEl); // className → "MyEl", tag → "my-el"
define(MyEl, "my-el"); // explicit tag, className inferred
define(MyEl, "my-el", "MyEl"); // both explicit
class MyModel extends TurboModel { ... }
define(MyModel, undefined, "MyModel"); // non-element, registry only
The class name, used as the registry key and to infer the tag name.