Skip to content

@get-advantage/advantage / 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:43

Properties

#root

Private #root: ShadowRoot

Defined in

src/advantage/wrapper.ts:27


#slotAdvantageContent

Private #slotAdvantageContent: HTMLSlotElement

Defined in

src/advantage/wrapper.ts:28


#slotChangeRegistered

Private #slotChangeRegistered: boolean = false

Defined in

src/advantage/wrapper.ts:29


#styleSheet

Private #styleSheet: CSSStyleSheet | HTMLStyleElement

Defined in

src/advantage/wrapper.ts:26


allowedFormats

allowedFormats: null | string[] = null

Implementation of

IAdvantageWrapper.allowedFormats

Defined in

src/advantage/wrapper.ts:31


container

container: HTMLDivElement

Implementation of

IAdvantageWrapper.container

Defined in

src/advantage/wrapper.ts:33


content

content: HTMLDivElement

Implementation of

IAdvantageWrapper.content

Defined in

src/advantage/wrapper.ts:34


currentFormat

currentFormat: string = ""

Implementation of

IAdvantageWrapper.currentFormat

Defined in

src/advantage/wrapper.ts:36


messageHandler

messageHandler: AdvantageAdSlotResponder

Defined in

src/advantage/wrapper.ts:37


simulating

simulating: boolean = false

Defined in

src/advantage/wrapper.ts:38


uiLayer

uiLayer: IAdvantageUILayer

Implementation of

IAdvantageWrapper.uiLayer

Defined in

src/advantage/wrapper.ts:35

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

Methods

#detectDOMChanges

#detectDOMChanges(): void

Detects DOM changes and resets the wrapper if a new ad is loaded.

Returns

void

Defined in

src/advantage/wrapper.ts:115


animateClose

animateClose(): void

Returns

void

Implementation of

IAdvantageWrapper.animateClose

Defined in

src/advantage/wrapper.ts:381


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


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


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


close

close(): void

Closes the current ad format.

Returns

void

Implementation of

IAdvantageWrapper.close

Defined in

src/advantage/wrapper.ts:392


connectedCallback

connectedCallback(): void

Lifecycle method called when the element is connected to the DOM.

Returns

void

Defined in

src/advantage/wrapper.ts:468


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


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


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


reset

reset(): void

Resets the current ad format.

Returns

void

Implementation of

IAdvantageWrapper.reset

Defined in

src/advantage/wrapper.ts:357


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


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


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