Skip to content

createSvg<K>

Creates an element in the SVG namespace and applies its options: class and attributes, then appends it to parent (or prepends it when prepend is set).

Import:

import 'obsidian-test-mocks/setup';

Signature:

function createSvg(tag: K, o: string | SvgElementInfo | undefined, callback: ((el: SVGElementTagNameMap[K]) => void) | undefined): SVGElementTagNameMap[K]

Parameters:

Parameter Type Description
tag K The tag name of the SVG element to create.
o string | SvgElementInfo | undefined A class name, or the element’s options; a null attribute value removes that attribute.
callback ((el: SVGElementTagNameMap[K]) => void) | undefined Called with the new element after the options are applied.

Returns: SVGElementTagNameMap[K] — The new SVG element.