Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat]: Better handling when translations are undefined #650

Open
hrasekj opened this issue Feb 26, 2024 · 0 comments
Open

[Feat]: Better handling when translations are undefined #650

hrasekj opened this issue Feb 26, 2024 · 0 comments
Labels
enhancement New feature or request triage yet to be reviewed

Comments

@hrasekj
Copy link

hrasekj commented Feb 26, 2024

Description

Hello,

so i had this bug in my code, when my function didn't return object with traslations for ConsentModal. Which led to state._currentTranslation.consentModal be undefined and function createConsentModal did not create any html elements. This led to unrelated errors about missing dom elements. CookieConsent was trying add events and attributes even, when props like dom._cm where undefined.

Proposed solution

In createConsentModal should be atleast console.warn or throw?

const createConsentModal = (api, createMainContainer) => {
  // ...

  /**
   * @type {import("../global").ConsentModalOptions}
   */
  const consentModalData = state._currentTranslation && state._currentTranslation.consentModal;

  if (!consentModalData) {
    // console.warn('consentModalData is undefined');
    // throw new Error('consentModalData is undefined');
    return;
  }

  // ...

Additional details

No response

@hrasekj hrasekj added enhancement New feature or request triage yet to be reviewed labels Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage yet to be reviewed
Projects
None yet
Development

No branches or pull requests

1 participant