Skip to content

Commit b1d044c

Browse files
authored
Revert "Render mobile sticky ads only if reader revenue banner is absent (#2351)"
This reverts commit a001baf.
1 parent 226f6d6 commit b1d044c

2 files changed

Lines changed: 19 additions & 94 deletions

File tree

bundle/playwright/tests/mobile-sticky-slot.spec.ts

Lines changed: 0 additions & 65 deletions
This file was deleted.

bundle/src/insert/mobile-sticky.ts

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { log } from '@guardian/libs';
21
import { createAdSlot } from '../lib/create-ad-slot';
32
import fastdom from '../lib/fastdom-promise';
43
import { shouldIncludeMobileSticky } from '../lib/header-bidding/utils';
@@ -32,36 +31,27 @@ const createAdWrapper = () => {
3231
* Initialise mobile sticky ad slot
3332
* @returns Promise
3433
*/
35-
36-
const renderMobileStickySlot = async () => {
37-
log('commercial', '🪵 Rendering MobileSticky');
38-
const mobileStickyWrapper = createAdWrapper();
39-
await fastdom.mutate(() => {
40-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Is body really always defined?
41-
if (document.body && mobileStickyWrapper) {
42-
document.body.appendChild(mobileStickyWrapper);
43-
}
44-
});
45-
if (mobileStickyWrapper) {
46-
const mobileStickyAdSlot =
47-
mobileStickyWrapper.querySelector<HTMLElement>(
48-
'#dfp-ad--mobile-sticky',
49-
);
50-
if (mobileStickyAdSlot) {
51-
void fillDynamicAdSlot(mobileStickyAdSlot, true);
52-
}
53-
}
54-
};
55-
5634
export const init = (): Promise<void> => {
57-
const handleBannerEvent = () => {
58-
log('commercial', '🪵 Handle Banner Event');
59-
void renderMobileStickySlot();
60-
};
61-
6235
if (shouldIncludeMobileSticky()) {
63-
document.addEventListener('banner:close', handleBannerEvent);
64-
document.addEventListener('banner:none', handleBannerEvent);
36+
const mobileStickyWrapper = createAdWrapper();
37+
return fastdom
38+
.mutate(() => {
39+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Is body really always defined?
40+
if (document.body && mobileStickyWrapper) {
41+
document.body.appendChild(mobileStickyWrapper);
42+
}
43+
})
44+
.then(() => {
45+
if (mobileStickyWrapper) {
46+
const mobileStickyAdSlot =
47+
mobileStickyWrapper.querySelector<HTMLElement>(
48+
'#dfp-ad--mobile-sticky',
49+
);
50+
if (mobileStickyAdSlot) {
51+
void fillDynamicAdSlot(mobileStickyAdSlot, true);
52+
}
53+
}
54+
});
6555
}
6656

6757
return Promise.resolve();

0 commit comments

Comments
 (0)