Merge pull request #5725 from mermaid-js/sidv/copyInitOptions

fix: Create a copy of config passed in initialize, so that theme variables are not leaked to the object
This commit is contained in:
Knut Sveidqvist
2024-08-20 14:45:00 +02:00
committed by GitHub
2 changed files with 5 additions and 3 deletions

View File

@@ -25,6 +25,7 @@ import { preprocessDiagram } from './preprocess.js';
import { decodeEntities } from './utils.js';
import { toBase64 } from './utils/base64.js';
import type { D3Element, ParseOptions, ParseResult, RenderResult } from './types.js';
import assignWithDepth from './assignWithDepth.js';
const MAX_TEXTLENGTH = 50_000;
const MAX_TEXTLENGTH_EXCEEDED_MSG =
@@ -473,9 +474,10 @@ const render = async function (
};
/**
* @param options - Initial Mermaid options
* @param userOptions - Initial Mermaid options
*/
function initialize(options: MermaidConfig = {}) {
function initialize(userOptions: MermaidConfig = {}) {
const options = assignWithDepth({}, userOptions);
// Handle legacy location of font-family configuration
if (options?.fontFamily && !options.themeVariables?.fontFamily) {
if (!options.themeVariables) {