Skip to content

lit-ui-router / SrefHrefDirective

Class: SrefHrefDirective

Defined in: packages/lit-ui-router/src/sref-href.ts:35

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(). Everything that needs the element (finding the router, the click handler, the target event for an enclosing uiSrefActive) lives in update(), which only a live document runs. Handing the directive a router without an element is the remaining server-side piece.

See

srefHref for the public API

Extends

Properties

PropertyTypeDefault valueDescriptionDefined in
hrefstring | nullnullthe href computed for the target, or null when there is nonepackages/lit-ui-router/src/sref-href.ts:52
optionsTransitionOptions{}the transition options from the last renderpackages/lit-ui-router/src/sref-href.ts:41
paramsRawParams{}the target state params from the last renderpackages/lit-ui-router/src/sref-href.ts:39
statestring | nullnullthe target state name from the last renderpackages/lit-ui-router/src/sref-href.ts:37
targetState| TargetState | nullnullthe resolved target, or null until the router is foundpackages/lit-ui-router/src/sref-href.ts:54

Methods

render()

ts
render(
   state, 
   params?, 
   options?
): string | typeof noChange | typeof nothing;

Defined in: packages/lit-ui-router/src/sref-href.ts:86

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.

Parameters

ParameterType
statestring
params?RawParams
options?TransitionOptions

Returns

string | typeof noChange | typeof nothing

Overrides

ts
AsyncDirective.render