question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

removeEventListener callback is called with null if tcData is enriched.

See original GitHub issue

Version

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

  1. 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);
  }
})
  1. Invoke init command. CMP works fine.

  2. Invoke addEventListener and removeEventListener 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);
  1. removed parameter is always null

What is the expected behavior?

According to the specs removeEventListener callback should be called with a boolean.


Thank you!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:10

github_iconTop GitHub Comments

1reaction
shortaflipcommented, Sep 22, 2021

iabtcf-es library v1.3.1 that contains changes that addressed this issue has been released.

1reaction
shortaflipcommented, Sep 7, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found