fix(interactive): add fallback to documentElement for SVG access

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 <object> 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 <noreply@anthropic.com>
This commit is contained in:
TheFlow 2025-10-19 15:57:11 +13:00
parent df8ac169d1
commit 52a1f9a3c4

View file

@ -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;
}