lit-ui-router / SrefHrefDirective
Class: SrefHrefDirective
Defined in: packages/lit-ui-router/src/sref-href.ts:36
The attribute-part sibling of UiSrefDirective: the same link, bound where the href lives instead of on the element.
render() is a function of the router and the arguments alone — it returns the href and touches no DOM — which is the shape a server renderer needs, since it runs render() and never update(). It finds its router from the element in a document and from the server's render-scoped router under @lit-labs/ssr. Everything else that needs the element (the click handler, the target event for an enclosing uiSrefActive) lives in update(), which only a live document runs.
See
srefHref for the public API
Extends
Properties
| Property | Type | Default value | Description | Defined in |
|---|---|---|---|---|
href | string | null | null | the href computed for the target, or null when there is none | packages/lit-ui-router/src/sref-href.ts:53 |
options | TransitionOptions | {} | the transition options from the last render | packages/lit-ui-router/src/sref-href.ts:42 |
params | RawParams | {} | the target state params from the last render | packages/lit-ui-router/src/sref-href.ts:40 |
state | string | null | null | the target state name from the last render | packages/lit-ui-router/src/sref-href.ts:38 |
targetState | | TargetState | null | null | the resolved target, or null until the router is found | packages/lit-ui-router/src/sref-href.ts:55 |
Methods
render()
render(
state,
params?,
options?
): string | typeof noChange | typeof nothing;Defined in: packages/lit-ui-router/src/sref-href.ts:90
The href for the target state; nothing when the state has no url; noChange until a router is found, so an attribute a server wrote survives hydration untouched.
The scoped slot is read per render rather than cached: a server directive instance renders once, and a client one never finds a scoped router.
Parameters
| Parameter | Type |
|---|---|
state | string |
params? | RawParams |
options? | TransitionOptions |
Returns
string | typeof noChange | typeof nothing
Overrides
AsyncDirective.render