From 52a1f9a3c4f6e0f753740647ee2d97edbeda5fef Mon Sep 17 00:00:00 2001 From: TheFlow Date: Sun, 19 Oct 2025 15:57:11 +1300 Subject: [PATCH] fix(interactive): add fallback to documentElement for SVG access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SUMMARY: Fixed "SVG diagram not found in contentDocument" error by adding fallback to use documentElement when getElementById doesn't find SVG. ISSUE: When SVG is loaded via tag, sometimes getElementById() doesn't find the SVG element even though it exists in contentDocument. FIX: Added fallback logic: 1. Try svgDoc.getElementById('interactive-arch-diagram') 2. If not found, try svgDoc.documentElement (the root SVG element) 3. Verify element is actually an SVG before proceeding This ensures the interactive diagram works regardless of how the browser parses the SVG document structure. 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude --- public/js/components/interactive-diagram.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/js/components/interactive-diagram.js b/public/js/components/interactive-diagram.js index d91be405..800bfe2b 100644 --- a/public/js/components/interactive-diagram.js +++ b/public/js/components/interactive-diagram.js @@ -125,8 +125,15 @@ class InteractiveDiagram { return; } - const svg = svgDoc.getElementById('interactive-arch-diagram'); + // The SVG is the document element itself, or we can query for it + let svg = svgDoc.getElementById('interactive-arch-diagram'); if (!svg) { + // Try getting the root SVG element + svg = svgDoc.documentElement; + console.log('[InteractiveDiagram] Using documentElement as SVG'); + } + + if (!svg || svg.tagName !== 'svg') { console.warn('[InteractiveDiagram] SVG diagram not found in contentDocument'); return; }