code syntax improvment (initialize func)

This commit is contained in:
salah alhashmi
2022-08-03 14:16:02 +04:00
parent f7c5e1b8b2
commit fb6bf87161

View File

@@ -491,23 +491,20 @@ function updateRendererConfigs(conf) {
/** @param {any} options */ /** @param {any} options */
function initialize(options) { function initialize(options) {
// Handle legacy location of font-family configuration // Handle legacy location of font-family configuration
if (options && options.fontFamily) { if (options?.fontFamily) {
if (!options.themeVariables) { if (!options.themeVariables?.fontFamily) {
options.themeVariables = { fontFamily: options.fontFamily };
} else {
if (!options.themeVariables.fontFamily) {
options.themeVariables = { fontFamily: options.fontFamily }; options.themeVariables = { fontFamily: options.fontFamily };
} }
} }
}
// Set default options // Set default options
configApi.saveConfigFromInitialize(options); configApi.saveConfigFromInitialize(options);
if (options && options.theme && theme[options.theme]) { if (options?.theme && theme[options.theme]) {
// Todo merge with user options // Todo merge with user options
options.themeVariables = theme[options.theme].getThemeVariables(options.themeVariables); options.themeVariables = theme[options.theme].getThemeVariables(options.themeVariables);
} else { } else if (options) {
if (options) options.themeVariables = theme.default.getThemeVariables(options.themeVariables); options.themeVariables = theme.default.getThemeVariables(options.themeVariables);
} }
const config = const config =