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:63

Properties ​

#activeFormatIframe ​

• Private #activeFormatIframe: null | HTMLIFrameElement = null

Defined in ​

src/advantage/wrapper.ts:41


#activeLifecycle ​

• Private Optional #activeLifecycle: Object

Type declaration ​

NameType
configMergedIntegrationConfig
formatAdvantageFormat
integration?AdvantageFormatIntegration

Defined in ​

src/advantage/wrapper.ts:42


#disconnectTimeout ​

• Private #disconnectTimeout: null | Timeout = null

Defined in ​

src/advantage/wrapper.ts:49


#mutationObserver ​

• Private #mutationObserver: null | MutationObserver = null

Defined in ​

src/advantage/wrapper.ts:47


#root ​

• Private #root: ShadowRoot

Defined in ​

src/advantage/wrapper.ts:37


#slotAdvantageContent ​

• Private #slotAdvantageContent: HTMLSlotElement

Defined in ​

src/advantage/wrapper.ts:38


#slotChangeHandler ​

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

Defined in ​

src/advantage/wrapper.ts:48


#slotChangeRegistered ​

• Private #slotChangeRegistered: boolean = false

Defined in ​

src/advantage/wrapper.ts:39


#styleSheet ​

• Private #styleSheet: CSSStyleSheet | HTMLStyleElement

Defined in ​

src/advantage/wrapper.ts:36


#trackedIframes ​

• Private #trackedIframes: WeakSet<HTMLIFrameElement>

Defined in ​

src/advantage/wrapper.ts:40


allowedFormats ​

• allowedFormats: null | string[] = null

Implementation of ​

IAdvantageWrapper.allowedFormats

Defined in ​

src/advantage/wrapper.ts:51


container ​

• container: HTMLDivElement

Implementation of ​

IAdvantageWrapper.container

Defined in ​

src/advantage/wrapper.ts:53


content ​

• content: HTMLDivElement

Implementation of ​

IAdvantageWrapper.content

Defined in ​

src/advantage/wrapper.ts:54


currentFormat ​

• currentFormat: string = ""

Implementation of ​

IAdvantageWrapper.currentFormat

Defined in ​

src/advantage/wrapper.ts:56


messageHandler ​

• messageHandler: AdvantageAdSlotResponder

Defined in ​

src/advantage/wrapper.ts:57


simulating ​

• simulating: boolean = false

Defined in ​

src/advantage/wrapper.ts:58


uiLayer ​

• uiLayer: IAdvantageUILayer

Implementation of ​

IAdvantageWrapper.uiLayer

Defined in ​

src/advantage/wrapper.ts:55


DISCONNECT_TIMEOUT_MS ​

▪ Static Readonly DISCONNECT_TIMEOUT_MS: 100

Defined in ​

src/advantage/wrapper.ts:33

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:252

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:177


#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:159


#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:148


animateClose ​

▸ animateClose(callback?): void

Parameters ​

NameType
callback?() => void

Returns ​

void

Implementation of ​

IAdvantageWrapper.animateClose

Defined in ​

src/advantage/wrapper.ts:560


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:642


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:483


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:284


close ​

▸ close(): Promise<void>

Closes the current ad format.

Returns ​

Promise<void>

Implementation of ​

IAdvantageWrapper.close

Defined in ​

src/advantage/wrapper.ts:582


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:743


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:714


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:444


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:659


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:297


reset ​

▸ reset(): Promise<void>

Resets the current ad format.

Returns ​

Promise<void>

Implementation of ​

IAdvantageWrapper.reset

Defined in ​

src/advantage/wrapper.ts:507


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:702


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:277


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:260