Source code
Revision control
Copy as Markdown
Other Tools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
// Corrections to the SVG that Mermaid draws, applied whenever a diagram is
// drawn or redrawn.
// Mermaid sets a sequence diagram's height attribute to the height of its
// layout, without the room its viewBox adds for a title and, in the neo look,
// for the actor boxes. The browser then scales the whole drawing down to fit
// that height.
const SEQUENCE = 'svg[aria-roledescription="sequence"][height][viewBox]';
document.addEventListener("DOMContentLoaded", () => {
new MutationObserver(() => {
for (const svg of document.querySelectorAll(SEQUENCE)) {
const { height } = svg.viewBox.baseVal;
if (svg.getAttribute("height") != height) {
svg.setAttribute("height", height);
}
}
}).observe(document.body, { childList: true, subtree: true });
});