Skip to content

Commit

Permalink
Use a variable to store event.source and manually deallocate after tc…
Browse files Browse the repository at this point in the history
…fapi call
  • Loading branch information
nching-publift committed Jul 12, 2024
1 parent a06f815 commit 161da32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/stub/src/stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
const payload = (typeof json === 'object' && json !== null) ? json.__tcfapiCall : null;

if (payload) {
let eventSource = event?.source;
window.__tcfapi(
payload.command,
payload.version,
Expand All @@ -103,12 +104,13 @@
},
};

if (event && event.source && event.source.postMessage) {
event.source.postMessage((msgIsString) ? JSON.stringify(returnMsg) : returnMsg, '*');
if (eventSource && eventSource.postMessage) {
eventSource.postMessage((msgIsString) ? JSON.stringify(returnMsg) : returnMsg, '*');
}
},
payload.parameter,
);
eventSource = null;
}
}

Expand Down

0 comments on commit 161da32

Please sign in to comment.