Skip to content

Commit

Permalink
TW-1222 Additional fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
keshan3262 committed Dec 21, 2023
1 parent 9bfcca8 commit 1ef5fd5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
16 changes: 5 additions & 11 deletions src/lib/slise/get-ads-containers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const getAdsContainers = ({ providersSelector, adPlacesRules }: SliseAdsD
}

return {
...getFinalSize(banner),
...getFinalSize(element),
element: element as HTMLElement,
shouldUseDivWrapper,
divWrapperStyle,
Expand All @@ -74,23 +74,17 @@ export const getAdsContainers = ({ providersSelector, adPlacesRules }: SliseAdsD
if (
element &&
!adsContainers.some(
({ element: duplicateCandidate }) => duplicateCandidate === element || duplicateCandidate.contains(element)
({ element: duplicateCandidate }) =>
duplicateCandidate.contains(element) || element.contains(duplicateCandidate)
)
) {
const childIndex = adsContainers.findIndex(({ element: childCandidate }) => element.contains(childCandidate));
const adContainer = {
adsContainers.push({
...getFinalSize(banner),
element,
shouldUseDivWrapper: false,
divWrapperStyle: {},
shouldNeglectSizeConstraints: false
};

if (childIndex === -1) {
adsContainers.push(adContainer);
} else {
adsContainers.splice(childIndex, 1, adContainer);
}
});
}
});

Expand Down
6 changes: 4 additions & 2 deletions src/lib/slise/mount-slise-ad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const isTWSliseAd = (element: Element) =>
element.className === 'adsbyslise' &&
element.attributes.getNamedItem('data-ad-pub')?.value === PUBLISHER_ID;

export const mountSliseAd = (element: HTMLElement, width: number, height: number) => {
export const mountSliseAd = (element: HTMLElement, width: number, height: number, displayBlock = false) => {
const children = element.children;

if ([...children].some(isTWSliseAd)) {
Expand All @@ -23,7 +23,9 @@ export const mountSliseAd = (element: HTMLElement, width: number, height: number
ins.className = 'adsbyslise';
ins.style.width = `${width}px`;
ins.style.height = `${height}px`;
ins.style.display = 'block';
if (displayBlock) {
ins.style.display = 'block';
}
ins.setAttribute('data-ad-slot', slotId);
ins.setAttribute('data-ad-pub', PUBLISHER_ID);
ins.setAttribute('data-ad-format', `${width}x${height}`);
Expand Down
Loading

0 comments on commit 1ef5fd5

Please sign in to comment.