Resolve every palette token in serialized SVG markup to a concrete colour.
The tooth artwork is painted through CSS custom properties, which a browser
resolves against the cascade of the document the markup lives in. An export
leaves that document: XMLSerializer produces a standalone SVG that is
written to a file or rasterized through an <img>, and in that isolated
context the host page's --odon-* values do not apply — every token would
silently fall back to its default, so a themed chart would export in the
stock colours.
This flattens them first, reading each token's value from element (custom
properties inherit, so the chart's own node sees the host's cascade). A
token the host never set resolves to "" and keeps its own fallback, which
makes an unthemed export byte-identical to one produced before theming
existed.
Parameters
xml: string
Serialized SVG markup.
Optionalelement: Element
The node to resolve token values against. Defaults to the
document element; pass the chart's own container when one is at hand.
Resolve every palette token in serialized SVG markup to a concrete colour.
The tooth artwork is painted through CSS custom properties, which a browser resolves against the cascade of the document the markup lives in. An export leaves that document:
XMLSerializerproduces a standalone SVG that is written to a file or rasterized through an<img>, and in that isolated context the host page's--odon-*values do not apply — every token would silently fall back to its default, so a themed chart would export in the stock colours.This flattens them first, reading each token's value from
element(custom properties inherit, so the chart's own node sees the host's cascade). A token the host never set resolves to""and keeps its own fallback, which makes an unthemed export byte-identical to one produced before theming existed.