Skip to content

@serenity-is/domwise / inNamespaceURI

Function: inNamespaceURI()

inNamespaceURI(namespaceURI, children): ComponentChildren

Defined in: src/in-namespace-uri.ts:45

Executes a children factory within a scoped namespace URI.

Temporarily sets currentNamespaceURI to namespaceURI for the duration of children(), then restores the previous value (even if the factory throws). This lets you create SVG/MathML subtrees imperatively without setting namespaceURI on every element.

Parameters

namespaceURI

Namespace URI to activate, or null for the HTML namespace.

string | null

children

() => ComponentChildren

Factory that produces the children to render in the given namespace.

Returns

ComponentChildren

The children returned by the factory.

Example

const icon = inNamespaceURI(SVGNamespace, () => <><circle r={10} /><path d="M0 0" /></>);