Skip to content

highimpact.js / advantage/wrapper / AdvantageWrapper

Class: AdvantageWrapper ​

advantage/wrapper.AdvantageWrapper

Represents the AdvantageWrapper class, which extends the HTMLElement class and implements the IAdvantageWrapper interface. This class is responsible for creating and managing the wrapper element for Advantage ads.

Hierarchy ​

  • HTMLElement

    ↳ AdvantageWrapper

Implements ​

Constructors ​

constructor ​

• new AdvantageWrapper(): AdvantageWrapper

Creates an instance of AdvantageWrapper.

Returns ​

AdvantageWrapper

Overrides ​

HTMLElement.constructor

Defined in ​

src/advantage/wrapper.ts:52

Properties ​

#activeFormatIframe ​

• Private #activeFormatIframe: null | HTMLIFrameElement = null

Defined in ​

src/advantage/wrapper.ts:35


#disconnectTimeout ​

• Private #disconnectTimeout: null | Timeout = null

Defined in ​

src/advantage/wrapper.ts:38


#mutationObserver ​

• Private #mutationObserver: null | MutationObserver = null

Defined in ​

src/advantage/wrapper.ts:36


#root ​

• Private #root: ShadowRoot

Defined in ​

src/advantage/wrapper.ts:31


#slotAdvantageContent ​

• Private #slotAdvantageContent: HTMLSlotElement

Defined in ​

src/advantage/wrapper.ts:32


#slotChangeHandler ​

• Private #slotChangeHandler: null | () => void = null

Defined in ​

src/advantage/wrapper.ts:37


#slotChangeRegistered ​

• Private #slotChangeRegistered: boolean = false

Defined in ​

src/advantage/wrapper.ts:33


#styleSheet ​

• Private #styleSheet: CSSStyleSheet | HTMLStyleElement

Defined in ​

src/advantage/wrapper.ts:30


#trackedIframes ​

• Private #trackedIframes: WeakSet<HTMLIFrameElement>

Defined in ​

src/advantage/wrapper.ts:34


allowedFormats ​

• allowedFormats: null | string[] = null

Implementation of ​

IAdvantageWrapper.allowedFormats

Defined in ​

src/advantage/wrapper.ts:40


container ​

• container: HTMLDivElement

Implementation of ​

IAdvantageWrapper.container

Defined in ​

src/advantage/wrapper.ts:42


content ​

• content: HTMLDivElement

Implementation of ​

IAdvantageWrapper.content

Defined in ​

src/advantage/wrapper.ts:43


currentFormat ​

• currentFormat: string = ""

Implementation of ​

IAdvantageWrapper.currentFormat

Defined in ​

src/advantage/wrapper.ts:45


messageHandler ​

• messageHandler: AdvantageAdSlotResponder

Defined in ​

src/advantage/wrapper.ts:46


simulating ​

• simulating: boolean = false

Defined in ​

src/advantage/wrapper.ts:47


uiLayer ​

• uiLayer: IAdvantageUILayer

Implementation of ​

IAdvantageWrapper.uiLayer

Defined in ​

src/advantage/wrapper.ts:44


DISCONNECT_TIMEOUT_MS ​

▪ Static Readonly DISCONNECT_TIMEOUT_MS: 100

Defined in ​

src/advantage/wrapper.ts:27

Accessors ​

contentNodes ​

• get contentNodes(): Node[]

Gets the content nodes assigned to the advantage-ad-slot.

Returns ​

Node[]

An array of content nodes.

Implementation of ​

IAdvantageWrapper.contentNodes

Defined in ​

src/advantage/wrapper.ts:241

Methods ​

#detectDOMChanges ​

▸ #detectDOMChanges(): void

Detects DOM changes and resets the wrapper if a new ad is loaded. Tracks iframes and resets the wrapper when an iframe that requested a format is removed.

Returns ​

void

Defined in ​

src/advantage/wrapper.ts:166


#dispatchLifecycleEvent ​

▸ #dispatchLifecycleEvent(eventName, format, iframe?): void

Dispatches a lifecycle CustomEvent that bubbles and crosses Shadow DOM boundaries.

Parameters ​

NameType
eventNamestring
formatstring
iframe?HTMLElement

Returns ​

void

Defined in ​

src/advantage/wrapper.ts:148


#updateCurrentFormatAttribute ​

▸ #updateCurrentFormatAttribute(): void

Updates the current-format attribute to match the currentFormat property. Sets the attribute when currentFormat has a value, removes it when empty.

Returns ​

void

Defined in ​

src/advantage/wrapper.ts:137


animateClose ​

▸ animateClose(callback?): void

Parameters ​

NameType
callback?() => void

Returns ​

void

Implementation of ​

IAdvantageWrapper.animateClose

Defined in ​

src/advantage/wrapper.ts:538


applyStylesToAllChildElements ​

▸ applyStylesToAllChildElements(styles): void

Applies styles to all child elements of the wrapper.

Parameters ​

NameTypeDescription
stylesstringThe CSS styles to apply.

Returns ​

void

Implementation of ​

IAdvantageWrapper.applyStylesToAllChildElements

Defined in ​

src/advantage/wrapper.ts:620


changeContent ​

▸ changeContent(content): void

Changes the content of the wrapper.

Parameters ​

NameTypeDescription
contentstring | HTMLElementThe new content to be added to the wrapper.

Returns ​

void

Implementation of ​

IAdvantageWrapper.changeContent

Defined in ​

src/advantage/wrapper.ts:461


clearAllowedFormats ​

▸ clearAllowedFormats(): void

Clears the programmatic whitelist so the wrapper falls back to attribute or default behaviour.

Returns ​

void

Implementation of ​

IAdvantageWrapper.clearAllowedFormats

Defined in ​

src/advantage/wrapper.ts:273


close ​

▸ close(): Promise<void>

Closes the current ad format.

Returns ​

Promise<void>

Implementation of ​

IAdvantageWrapper.close

Defined in ​

src/advantage/wrapper.ts:560


connectedCallback ​

▸ connectedCallback(): void

Lifecycle method called when the element is connected to the DOM. Clears the disconnect timeout if the element reconnects quickly.

Returns ​

void

Defined in ​

src/advantage/wrapper.ts:721


disconnectedCallback ​

▸ disconnectedCallback(): void

Lifecycle method called when the element is disconnected from the DOM. Uses a timeout to distinguish between temporary removal and actual cleanup.

Returns ​

void

Defined in ​

src/advantage/wrapper.ts:692


forceFormat ​

▸ forceFormat(format, iframe?, options?): Promise<void>

Forces a specific ad format without waiting for a message from the iframe. This allows publishers to directly control which format to display.

Parameters ​

NameTypeDescription
formatstringThe format to apply
iframe?HTMLIFrameElementThe iframe element to use for the ad (optional)
options?anyAdditional options to pass to the format's setup function

Returns ​

Promise<void>

A promise that resolves when the format has been applied

Implementation of ​

IAdvantageWrapper.forceFormat

Defined in ​

src/advantage/wrapper.ts:422


insertCSS ​

▸ insertCSS(CSS): void

Inserts CSS into the shadow root of the wrapper.

Parameters ​

NameTypeDescription
CSSstringThe CSS to insert.

Returns ​

void

Implementation of ​

IAdvantageWrapper.insertCSS

Defined in ​

src/advantage/wrapper.ts:637


morphIntoFormat ​

▸ morphIntoFormat(format, message?): Promise<void>

Morphs the wrapper into a specific ad format. If allowed-formats is set (via attribute or API) it takes precedence over exclude-formats. Comparisons are case-insensitive.

Parameters ​

NameTypeDescription
formatstringThe format to morph into.
message?AdvantageMessage-

Returns ​

Promise<void>

A promise that resolves when the morphing is complete.

Implementation of ​

IAdvantageWrapper.morphIntoFormat

Defined in ​

src/advantage/wrapper.ts:286


reset ​

▸ reset(): Promise<void>

Resets the current ad format.

Returns ​

Promise<void>

Implementation of ​

IAdvantageWrapper.reset

Defined in ​

src/advantage/wrapper.ts:485


resetCSS ​

▸ resetCSS(): void

Resets the CSS in the shadow root of the wrapper.

Returns ​

void

Implementation of ​

IAdvantageWrapper.resetCSS

Defined in ​

src/advantage/wrapper.ts:680


setAllowedFormats ​

▸ setAllowedFormats(formats): void

Restrict this wrapper to the given list of formats. Calling this method overrides any list previously set via attribute or API.

Parameters ​

NameTypeDescription
formatsstring[]Array of format names that are allowed for this wrapper.

Returns ​

void

Implementation of ​

IAdvantageWrapper.setAllowedFormats

Defined in ​

src/advantage/wrapper.ts:266


simulateFormat ​

▸ simulateFormat(format): Promise<void>

Simulates a specific ad format.

Parameters ​

NameTypeDescription
formatstringThe format to simulate.

Returns ​

Promise<void>

Implementation of ​

IAdvantageWrapper.simulateFormat

Defined in ​

src/advantage/wrapper.ts:249