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.
Comments
Comment #2
grayle commentedAPI 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...
Comment #3
svenryen commentedIt'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
PreStatusLoadtopreStatusLoadit 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.
Comment #4
svenryen commentedComment #7
svenryen commentedComment #8
svenryen commented