removeEventListener callback is called with null if tcData is enriched.
See original GitHub issueVersion
Problem is encountered in v1.3.0 and v1.2.1. Worked fine in 1.1.4.
Module (core, cmpapi, cli, stub, or testing)
cmpapi
Issue
removeEventListener
callback is called with null
instead of a boolean if tcData
is enriched.
It works as expected if tcData
is not enriched.
Reproduction steps
- Create a CMP:
const cmpApi = new CmpApi(CMP_PROVIDER_ID, CMP_VERSION, true, {
'getTCData': (next, tcData, success) => {
tcData.reallyImportantExtraProperty = true; // this causes the problem
next(tcData, success);
}
})
-
Invoke
init
command. CMP works fine. -
Invoke
addEventListener
andremoveEventListener
commands:
const callback = (tcData, success) => {
if(success) {
__tcfapi('removeEventListener', 2, (removed) => {
if(removed) {
// Never passes the condition, <removed> value is always null
}
}, tcData.listenerId);
} else {}
}
__tcfapi('addEventListener', 2, callback);
removed
parameter is alwaysnull
❌
What is the expected behavior?
According to the specs removeEventListener
callback should be called with a boolean.
Thank you!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10
Top Results From Across the Web
removeEventListener - callback within function definition itself?
the EventListener function (in your case gameStart ) is not called when calling removeEventListener , therefore there is not any circular ...
Read more >EventTarget.removeEventListener() - Web APIs | MDN
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.
Read more >__tcfapi function - addEventListener, removeEventListener ...
The addEventListener command registers a listener for a callback function with the CMP. The listener's callback function is triggered when ...
Read more >Cannot read property 'addEventListener' of null · Issue #6740 ...
I'm getting this error in the console when certain components are removed from the DOM. It's calling the method below, which assumes that ......
Read more >1.2.3.12 - Removing Event Listeners
In this lesson, we'll learn how to remove event listeners with the removeEventListener() method. In the applications that you build at ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
iabtcf-es library v1.3.1 that contains changes that addressed this issue has been released.
iabtcf-es library pre-release v1.3.1-0 is live. The pre-release will stay live for 2 weeks and barring any issues, will then transition to a full release.