mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-05 15:19:36 +02:00
use backtick for cleaner variable string and the DOM document for default values
This commit is contained in:
@@ -17,17 +17,15 @@ const draw: DrawDefinition = (text, id, version) => {
|
|||||||
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 document: Document | null | undefined;
|
let doc: Document = document;
|
||||||
if (securityLevel === 'sandbox') {
|
if (securityLevel === 'sandbox') {
|
||||||
const sandboxElement: HTML = select('#i' + id);
|
const sandboxElement: HTML = select(`#i${id}`);
|
||||||
document = sandboxElement.node()?.contentDocument;
|
doc = sandboxElement.node()?.contentDocument ?? doc;
|
||||||
}
|
}
|
||||||
const root: HTML =
|
const root: HTML =
|
||||||
document !== undefined && document !== null
|
securityLevel === 'sandbox' ? select(doc.body as HTMLIFrameElement) : select('body');
|
||||||
? select(document.body as HTMLIFrameElement)
|
|
||||||
: select('body');
|
|
||||||
|
|
||||||
const svg: SVG = root.select('#' + id);
|
const svg: SVG = root.select(`#${id}`);
|
||||||
svg.attr('height', 100);
|
svg.attr('height', 100);
|
||||||
svg.attr('width', 400);
|
svg.attr('width', 400);
|
||||||
|
|
||||||
@@ -38,7 +36,7 @@ const draw: DrawDefinition = (text, id, version) => {
|
|||||||
.attr('class', 'version')
|
.attr('class', 'version')
|
||||||
.attr('font-size', '32px')
|
.attr('font-size', '32px')
|
||||||
.style('text-anchor', 'middle')
|
.style('text-anchor', 'middle')
|
||||||
.text('v ' + version);
|
.text(`v${version}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error('error while rendering info diagram\n', e);
|
log.error('error while rendering info diagram\n', e);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user