@gluonjs/core / src/compat/lit / LitCompatElement
Abstract Class: LitCompatElement<Events>
Optional Lit lifecycle naming for components being migrated to Gluon.
The renderer, scheduler, connection scope, and error routing remain owned by GluonElement. New components should prefer Gluon's native lifecycle hooks.
Extends
GluonElement<Events>
Type Parameters
Events
Events extends object = Record<string, unknown>
Constructors
Constructor
new LitCompatElement<
Events>():LitCompatElement<Events>
Returns
LitCompatElement<Events>
Overrides
Properties
renderRoot
protectedreadonlyrenderRoot:ShadowRoot
Shadow root rendered by update; override createRenderRoot to customize it.
Inherited from
events
readonlystaticevents:Readonly<Record<string,EventDeclaration<any>>> ={}
Declares native output events and their propagation, cancellation, and validation rules.
Inherited from
properties
readonlystaticproperties:Readonly<Record<string,PropertyDefinition<any>>> ={}
Declares reactive inputs and their attribute conversion, reflection, and validation rules.
Inherited from
shadowRootRegistry?
readonlystaticoptionalshadowRootRegistry?:GluonElementRegistry
Optional explicit registry associated with this element's ShadowRoot.
Inherited from
GluonElement.shadowRootRegistry
slots
readonlystaticslots:SlotDeclarations={}
Declares required named/default slots and whether the template supplies fallback content.
Inherited from
styles
readonlystaticstyles:CSSStyleSheet| readonlyCSSStyleSheet[] =[]
Lists constructable stylesheets adopted into each instance's render root.
Inherited from
Accessors
changedProperties
Get Signature
get
protectedchangedProperties():ReadonlyMap<PropertyKey,unknown>
Returns the old values collected for the current update pass.
This is primarily a protected integration point for compatibility layers; native Gluon components should continue to use the lifecycle callbacks and reactive state directly.
Returns
ReadonlyMap<PropertyKey, unknown>
Inherited from
GluonElement.changedProperties
updateComplete
Get Signature
get updateComplete():
Promise<void>
Resolves after the currently scheduled render and its update hooks finish.
Returns
Promise<void>
Inherited from
observedAttributes
Get Signature
get
staticobservedAttributes():string[]
Attribute names derived from properties; managed by Gluon for the Custom Elements platform.
Returns
string[]
Inherited from
GluonElement.observedAttributes
Methods
attributeChangedCallback()
attributeChangedCallback(
name,oldValue,value):void
Converts a changed declared attribute and writes the corresponding property.
Parameters
name
string
oldValue
string | null
value
string | null
Returns
void
Inherited from
GluonElement.attributeChangedCallback
beginHydration()
beginHydration():
void
Defers the first connection render while official hydration binds declarative Shadow DOM.
Returns
void
Inherited from
connectedCallback()
connectedCallback():
void
Lit-compatible platform lifecycle entry point; always call super.
Returns
void
Overrides
GluonElement.connectedCallback
createRenderRoot()
protectedcreateRenderRoot():ShadowRoot
Creates the component render root. Override only when the default open ShadowRoot is unsuitable.
Returns
ShadowRoot
Inherited from
disconnectedCallback()
disconnectedCallback():
void
Lit-compatible platform lifecycle entry point; always call super.
Returns
void
Overrides
GluonElement.disconnectedCallback
emit()
protectedemit<Name>(type,detail,init?):boolean
Dispatches a typed native CustomEvent using the matching static event declaration.
Events bubble and cross the Shadow DOM boundary by default. The return value is false only when a cancelable event was canceled by a listener.
Type Parameters
Name
Name extends string
Parameters
type
Name
detail
Events[Name]
init?
Omit<CustomEventInit<Events[Name]>, "detail"> = {}
Returns
boolean
Inherited from
endHydration()
endHydration():
void
Resumes connection rendering after official hydration installs the hydrated root.
Returns
void
Inherited from
expose()
protectedexpose<Public>(value):Readonly<Public>
Publishes a frozen, deliberately small public object for use with exposedRef().
Type Parameters
Public
Public extends object
Parameters
value
Public
Returns
Readonly<Public>
Inherited from
firstUpdated()
protectedfirstUpdated(_changedProperties):void
Runs once after the first successful render of each connection.
Parameters
_changedProperties
Returns
void
onBeforeUpdate()
protectedonBeforeUpdate(callback):void
Runs a callback before every update after the first render.
Parameters
callback
Returns
void
Inherited from
onConnected()
protectedonConnected(callback):void
Runs a callback once after the first render of each connection.
Parameters
callback
Returns
void
Inherited from
onDisconnected()
protectedonDisconnected(callback):void
Runs a callback during disconnection after scoped reactive cleanup and render suspension.
Parameters
callback
Returns
void
Inherited from
onErrorCaptured()
protectedonErrorCaptured(callback):void
Captures descendant component errors; return true to stop propagation to outer boundaries.
Parameters
callback
Returns
void
Inherited from
onUpdated()
protectedonUpdated(callback):void
Runs a callback after every successful render, including the first render.
Parameters
callback
Returns
void
Inherited from
render()
abstractprotectedrender():TemplateResult
Returns the template for the current component state.
Returns
Inherited from
renderForServer()
renderForServer():
TemplateResult
Returns the component template without browser connection lifecycle for official server rendering.
Returns
Inherited from
requestHotUpdate()
requestHotUpdate():
Promise<void>
Requests a render pass after the official Vite runtime patches compatible logic. Application code should use normal reactive or property updates.
Returns
Promise<void>
Inherited from
requestUpdate()
requestUpdate(
_name?,_oldValue?):Promise<void>
Requests a Gluon update. The optional Lit arguments are accepted for migration ergonomics; Gluon collects actual declared-property changes.
Parameters
_name?
PropertyKey
_oldValue?
unknown
Returns
Promise<void>
Overrides
setupConnection()
protectedsetupConnection():void
Initializes work once per connection inside the connection's reactive effect scope.
Returns
void
Inherited from
teardownConnection()
protectedteardownConnection():void
Releases connection-local references after scoped cleanup and disconnect hooks.
Returns
void
Inherited from
GluonElement.teardownConnection
update()
protectedupdate():void
Commits the value returned by render into renderRoot.
Returns
void
Overrides
updated()
protectedupdated(_changedProperties):void
Runs after every successful Gluon render.
Parameters
_changedProperties
Returns
void
willUpdate()
protectedwillUpdate(_changedProperties):void
Runs before each Gluon render, including the first render of a connection.
Parameters
_changedProperties
Returns
void
Example
Extend the opt-in lifecycle bridge while leaving rendering and scheduling with Gluon:
import { LitCompatElement } from '@gluonjs/core/compat/lit';
import { html } from '@gluonjs/core';
class ProductCard extends LitCompatElement {
protected override render() {
return html`<article>Product</article>`;
}
}
console.log(ProductCard);