mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-10 17:49:40 +02:00
Update selectSvgElement.ts
This commit is contained in:
@@ -11,14 +11,12 @@ import type { HTML, SVG } from '../diagram-api/types.js';
|
|||||||
export const selectSvgElement = (id: string): SVG => {
|
export const selectSvgElement = (id: string): SVG => {
|
||||||
const { securityLevel } = getConfig();
|
const { securityLevel } = getConfig();
|
||||||
// handle root and document for when rendering in sandbox mode
|
// handle root and document for when rendering in sandbox mode
|
||||||
let doc: Document = document;
|
let root: HTML = select('body');
|
||||||
if (securityLevel === 'sandbox') {
|
if (securityLevel === 'sandbox') {
|
||||||
const sandboxElement: HTML = select(`#i${id}`);
|
const sandboxElement: HTML = select(`#i${id}`);
|
||||||
doc = sandboxElement.node()?.contentDocument ?? doc;
|
const doc: Document = sandboxElement.node()?.contentDocument ?? document;
|
||||||
|
root = select(doc.body as HTMLIFrameElement);
|
||||||
}
|
}
|
||||||
const root: HTML =
|
|
||||||
securityLevel === 'sandbox' ? select(doc.body as HTMLIFrameElement) : select('body');
|
|
||||||
|
|
||||||
const svg: SVG = root.select(`#${id}`);
|
const svg: SVG = root.select(`#${id}`);
|
||||||
return svg;
|
return svg;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user