Problem/Motivation

The API (post/preStatusLoad, etc) appears to be broken. At the very least I couldn't trigger a code snippet in a second module when a state trigger fired.

Steps to reproduce

1. Create a module with this script:

(function (Drupal) {

  'use strict';

  let PreStatusLoadHandler = function (response) {
    console.log(response);
    window.cookieResponse = response;
  };
  Drupal.eu_cookie_compliance('PreStatusLoad', PreStatusLoadHandler);

} (Drupal));

2. Reload the page and examine the console.
3. Note that the expected function caused no console output.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

svenryen created an issue. See original summary.

Grayle’s picture

API might be ripe for removal, it was added to facilitate integration with other modules, but those other modules are now just reading the cookie directly anyway. And it's hard to understand how it works as well, so maintaining it has become a chore.

So maybe we can remove it instead. Of course, we don't know if someone out there is actually using the API. But seeing as it's fully broken, and nobody but the maintainer noticed...

svenryen’s picture

It's not broken after all. It was caused by an error in the documentation. The two first events were given with a capital leading character (and I happened to pick the first event name when I set up the test), whereas the API expects lowercase for the first character. After changing my testing snippet from PreStatusLoad to preStatusLoad it worked like a charm.

Like you say, somebody might be using it, and we have been "yelled at" before for removing or changing functionality, so I'm a bit vary of removing something already added.

I'll commit a small patch to update documentation and this should be good to go.

svenryen’s picture

Title: API is possibly broken, can you check? » Documentation for API is misleading, inconsistent usage of upper and lower case

  • svenryen committed bd9715b on 8.x-1.x
    Issue #3310691 by svenryen, Grayle: Documentation for API is misleading...
svenryen’s picture

Status: Active » Fixed
svenryen’s picture

Assigned: Grayle » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.