Merge pull request #169 from reuters-graphics/ads-infinity

unset ad iframe width from CSS reset. cleanup ads slots onDestroy. En…
This commit is contained in:
Jon McClure 2024-08-20 10:58:33 +01:00 committed by GitHub
commit 1837dbb8e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View file

@ -39,7 +39,25 @@
window.graphicsAdQueue = window.graphicsAdQueue || [];
window.graphicsAdQueue.push(adSlot);
}
return () => {
// @ts-ignore
const freestar = window?.freestar;
if (freestar) {
freestar.queue.push(function () {
freestar.deleteAdSlots(adId);
});
}
};
});
</script>
<div data-freestar-ad="{dataFreestarAd || null}" id="{adId}"></div>
<style lang="scss">
div {
:global(iframe) {
width: auto;
}
}
</style>

View file

@ -6,6 +6,9 @@ interface attributesInterface {
export const loadScript = (src: string, attributes?: attributesInterface) => {
const { onload, async = true } = attributes || {};
const existingScript = document.querySelector(`script[src="${src}"]`);
if (existingScript) return;
const script = document.createElement('script');
script.addEventListener('load', onload);
script.async = async;