From fb6bf87161e00f93404897c8b56edede9d3b0558 Mon Sep 17 00:00:00 2001 From: salah alhashmi Date: Wed, 3 Aug 2022 14:16:02 +0400 Subject: [PATCH] code syntax improvment (initialize func) --- src/mermaidAPI.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/mermaidAPI.js b/src/mermaidAPI.js index 5b16c609a..8967adbdb 100644 --- a/src/mermaidAPI.js +++ b/src/mermaidAPI.js @@ -491,23 +491,20 @@ function updateRendererConfigs(conf) { /** @param {any} options */ function initialize(options) { // Handle legacy location of font-family configuration - if (options && options.fontFamily) { - if (!options.themeVariables) { + if (options?.fontFamily) { + if (!options.themeVariables?.fontFamily) { options.themeVariables = { fontFamily: options.fontFamily }; - } else { - if (!options.themeVariables.fontFamily) { - options.themeVariables = { fontFamily: options.fontFamily }; - } } } + // Set default options configApi.saveConfigFromInitialize(options); - if (options && options.theme && theme[options.theme]) { + if (options?.theme && theme[options.theme]) { // Todo merge with user options options.themeVariables = theme[options.theme].getThemeVariables(options.themeVariables); - } else { - if (options) options.themeVariables = theme.default.getThemeVariables(options.themeVariables); + } else if (options) { + options.themeVariables = theme.default.getThemeVariables(options.themeVariables); } const config =