v0.3.4
❗ Possible BC break if you are using an event CookieConsentWrapper.on('init', ...)
Removed
- Removed argument
wrapper
for an eventinit
. Callbacks for the event now have no arguments now, please use directlyCookieConsentWrapper
inside a callback function.
Why?
Internally event callbacks are stored in a "temporary" CookieConsentWrapper
object if the wrapper is not currently available e.g. the script cookie-consent.min.js
is not fully downloaded by a browser but you attaching some event callback.
At this point, the GTM can't provide the argument wrapper
into your callback because Template's code is sandboxed JavaScript, and custom objects like CookieConsentWrapper
instance are not supported by this sandbox so undefined
is passed as the argument instead of the wrapper.
How to modify your events
Simply call the wrapper directly inside a callback function. So instead of this:
CookieConsentWrapper.on('init', function (wrapper) {
# the wrapper argument is now undefined
wrapper.unwrap();
});
Use this:
CookieConsentWrapper.on('init', function () {
CookieConsentWrapper.unwrap();
});