From 30a66533bce0c302f4566c89587ad0ed51c30691 Mon Sep 17 00:00:00 2001 From: Yokozuna59 Date: Fri, 23 Jun 2023 23:26:45 +0300 Subject: [PATCH] use backtick for cleaner variable string and the DOM document for default values --- packages/mermaid/src/diagrams/info/infoRenderer.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/mermaid/src/diagrams/info/infoRenderer.ts b/packages/mermaid/src/diagrams/info/infoRenderer.ts index 33e886848..3950957ac 100644 --- a/packages/mermaid/src/diagrams/info/infoRenderer.ts +++ b/packages/mermaid/src/diagrams/info/infoRenderer.ts @@ -17,17 +17,15 @@ const draw: DrawDefinition = (text, id, version) => { const { securityLevel } = getConfig(); // handle root and document for when rendering in sandbox mode - let document: Document | null | undefined; + let doc: Document = document; if (securityLevel === 'sandbox') { - const sandboxElement: HTML = select('#i' + id); - document = sandboxElement.node()?.contentDocument; + const sandboxElement: HTML = select(`#i${id}`); + doc = sandboxElement.node()?.contentDocument ?? doc; } const root: HTML = - document !== undefined && document !== null - ? select(document.body as HTMLIFrameElement) - : select('body'); + securityLevel === 'sandbox' ? select(doc.body as HTMLIFrameElement) : select('body'); - const svg: SVG = root.select('#' + id); + const svg: SVG = root.select(`#${id}`); svg.attr('height', 100); svg.attr('width', 400); @@ -38,7 +36,7 @@ const draw: DrawDefinition = (text, id, version) => { .attr('class', 'version') .attr('font-size', '32px') .style('text-anchor', 'middle') - .text('v ' + version); + .text(`v${version}`); } catch (e) { log.error('error while rendering info diagram\n', e); }