fix(web): allow foreignObject in DOMPurify SVG, remove leftover loop code

- Add ADD_TAGS: ['foreignObject'] to all DOMPurify.sanitize calls —
  Mermaid uses foreignObject for HTML text labels inside flowchart
  nodes. The SVG profile was stripping them, causing empty boxes.
- Remove leftover sub-batch loop lines from prepared statement hoist

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jreakin 2026-03-23 10:01:55 -05:00
parent 83ec256cec
commit fd61cd2990
2 changed files with 1 additions and 7 deletions

View file

@ -71,7 +71,7 @@ export const MermaidDiagram = ({ code }: MermaidDiagramProps) => {
// Render the diagram
const { svg: renderedSvg } = await mermaid.render(id, code.trim());
const sanitizedSvg = DOMPurify.sanitize(renderedSvg, { USE_PROFILES: { svg: true, svgFilters: true } });
const sanitizedSvg = DOMPurify.sanitize(renderedSvg, { USE_PROFILES: { svg: true, svgFilters: true }, ADD_TAGS: ['foreignObject'] });
setSvg(sanitizedSvg);
setError(null);
} catch (err) {

View file

@ -267,12 +267,6 @@ export const loadGraphToLbug = async (
} finally {
await stmt.close();
}
// Yield to event loop between sub-batches
if (i + SUB_BATCH_SIZE < rels.length) {
await new Promise(r => setTimeout(r, 0));
}
}
}
if (import.meta.env.DEV) {