lit-ui-router / UIRouterLitElement
Class: UIRouterLitElement
Defined in: packages/lit-ui-router/src/ui-router.ts:48
Slots
- default —
<ui-router>renders slotted content.
Events
ui-router-context—<ui-router>listens to theui-router-contextevent and provides theuiRouterinstance. It answers the communitycontext-requestprotocol for {@link routerContext} from the same listener position, so an element built on@lit/contextgets the router too. The two paths coexist and neither sees the other's event: {@link UIRouterLitElement.seekRouter} asks onui-router-contextfirst and falls back to {@link requestRouter}.
Extends
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
uiRouter | UIRouterLit | undefined | Root uiRouter singleton. If not provided, the element creates and assigns a new instance. | packages/lit-ui-router/src/ui-router.ts:54 |
Methods
seekRouter()
static seekRouter(candidate): UIRouterLit | undefined;Defined in: packages/lit-ui-router/src/ui-router.ts:90
Discovers the UIRouterLit instance provided by the nearest enclosing <ui-router> element.
Dispatches a bubbling, composed ui-router-context event from the candidate element; the enclosing <ui-router> answers it with its router instance. Returns undefined when the candidate is not inside a <ui-router> (e.g. not yet connected).
This is the dependency-injection primitive for integrating external reactivity systems (state stores, controllers) with the router context — call it from hostConnected() / connectedCallback() instead of prop-drilling the router instance.
When no <ui-router> answers, it asks again with requestRouter, so an ancestor providing routerContext over the community protocol — a bare @lit/contextContextProvider, say — is found as well.
Parameters
| Parameter | Type |
|---|---|
candidate | Element |
Returns
UIRouterLit | undefined