From 68f8dcbc2e49e2e53c5ded698177eda333bdbb95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Litera?= Date: Fri, 22 Oct 2021 14:03:44 +0200 Subject: [PATCH] Fix: Incomplete options passed by user overrides all defaults * merge default options with passed arguments to guarantee * that incomplete options object from user do not override * all defaults options --- src/LmcCookieConsentManager.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/LmcCookieConsentManager.js b/src/LmcCookieConsentManager.js index 730fd259..8ece8478 100644 --- a/src/LmcCookieConsentManager.js +++ b/src/LmcCookieConsentManager.js @@ -7,7 +7,14 @@ import { config as configSk } from './languages/sk'; const defaultOptions = { currentLang: 'cs', themeCss: '', config: {} }; -const LmcCookieConsentManager = (options = defaultOptions) => { +/** + * @param {Object} args - Options for cookie consent manager + * @param {string} args.currentLang - Specify one of the languages you have defined + * @param {string} args.themeCss - Specify file to the .css file + * @param {Object} args.config - Override default config. See https://github.com/orestbida/cookieconsent/blob/master/Readme.md#all-available-options + */ +const LmcCookieConsentManager = (args) => { + const options = { ...defaultOptions, ...args }; const { currentLang, themeCss, config } = options; const cookieconsent = window.initCookieConsent();