Skip to content
D
Documentation

SerializeOptions

reference
1 min readUpdated

Import it from @grafloria/renderer.

ts
interface SerializeOptions

Properties

NameTypeDefaultDescription
fidelity?SerializeFidelityWho reads the output. Default 'file'. See {@link SerializeFidelity}.
standalone?booleanStamp xmlns on the root element (needed for a standalone .svg file).
classStyles?ClassStyleResolverResolves an element's classes to the presentation attributes the renderer's stylesheet would have painted. Omit for a tree rendered in programmatic mode (there is no stylesheet there — every value is already on the element). Ignored under fidelity: 'dom' — the client has the real stylesheet.
foreignObject?ForeignObjectModeHow to handle <foreignObject> subtrees. Default 'serialize'.
captureForeignObject?(vnode: VNode) => string | undefinedFaithful foreignObject export. The VNode tree does NOT contain the HTML a framework mounted into a foreignObject (the patcher treats those subtrees as opaque and never touches their children) — so a headless serializer CANNOT know what is in there. A browser-side caller that has the live DOM can hand the markup back through this hook (e.g.
warnings?string[]Collector for fidelity caveats hit while serializing.
extraDefs?Map<string, string>Collector for <defs> elements the serializer had to synthesize (blur filters).
html?booleanThis subtree is XHTML, not SVG (i.e. it is inside a <foreignObject>). Set automatically when recursing into one — HTML has no presentation attributes, so there the style attribute is kept verbatim and no class flattening is attempted (the host's own CSS, which we do not own, styles that content).

Was this page helpful?

SerializeOptions — Grafloria