Uncaught TypeError: etLoader is null

Created on 25 October 2022, almost 2 years ago
Updated 18 January 2024, 8 months ago

Problem/Motivation

Uncaught TypeError: etLoader is null is popping up in the console from these lines in modules/cookies_etracker/js/cookies_etracker-block_cookies_true_without_consent.js:

/**
 * @file
 * Defines Javascript behaviors for the cookies_etracker module.
 *
 * This is used when data_block_cookies is TRUE
 * AND knockout_mode is 'block_cookies_true_without_consent'.
 */
(function (Drupal) {
  /**
   * Sets data-block-cookies to "false" once consent was given
   * through COOKiES.
   */
  Drupal.behaviors.cookiesEtrackerBlockCookiesTrueWithoutConsent = {
    // id corresponding to the cookies_service.schema->id.
    id: "etracker",

    activate(context) {
      const etLoader = document.getElementById("_etLoader");
      if (
        etLoader.getAttribute &&
        etLoader.getAttribute("data-block-cookies") === "true"
      ) {
        // Use cookieful tracking:

This is minor, as it only happens under certain conditions, especially if etracker is disabled for the current role, path, etc. - in that case the script should not be executed at all, I guess.

Furthermore we could discuss, if in the following line a check for existence of the element should be added:
const etLoader = document.getElementById("_etLoader");

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    This is fixed in dev and 8.x-3.0-beta4, but I don't have permission to add a new release. This bug breaks existing sites through the JS error. @sunlix could you please add the new tagged release?

  • πŸ‡©πŸ‡ͺGermany sunlix Wesel

    Hey Julian,

    I am sorry wanted to have a look today, but a full bloat meeting schedule didn’t made any β€žworkβ€œ done.
    Added it tomorrow, hit me on Slack before 10h so I think we can spin off beta5

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @sunlix all good :) I was able to solve it. @jurgenhaas helped out and granted the required permissions.
    If you're interested, please have a look at the other open issues, maybe we can finish them soon. Hopefully not much work left here then :)

    Happy coding!

Production build 0.71.5 2024