Skip to content

Commit

Permalink
Fix: Incomplete options passed by user overrides all defaults
Browse files Browse the repository at this point in the history
  * merge default options with passed arguments to guarantee
  * that incomplete options object from user do not override
  * all defaults options
  • Loading branch information
literat committed Oct 25, 2021
1 parent d8238c3 commit 68f8dcb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/LmcCookieConsentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 68f8dcb

Please sign in to comment.