code syntax improvment (initialize func)

This commit is contained in:
salah alhashmi 2022-08-03 14:16:02 +04:00
parent f7c5e1b8b2
commit fb6bf87161
1 changed files with 6 additions and 9 deletions

View File

@ -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 =