-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: googletag.display errors when ad slot not in DOM (#142)
## Description This PR fixes an issue where GPT complains if googletag.displaySlots() is called for a defined ad slot that is not yet in the DOM, i.e. ``` GPT] Error in googletag.display: could not find div with id "my-ad-id" in DOM for slot: /my/ad/unit/path ``` - The fix is to defer the calling of `Advertising.displaySlots()`. So instead calling this method in `Advertising.setupGpt()`, we are now calling it at the end of `Advertising.active()`. - I've also refactored displaySlots() to accept an id and to only call `window.googletag.display(id)` for this single `id`, instead of iterating through all the slots - `Advertising.active()` gets called from the `AdvertisingSlot` component, so now Advertising.displaySlots() will not fire for defined ad slots that are not yet in the DOM. - The solution was based on a suggestion from @Trav84, as outlined in: https://github.com/orgs/KijijiCA/discussions/141 --------- Co-authored-by: Stephen Gill <stephen.gill@adevinta.com>
- Loading branch information
1 parent
bb3073b
commit 3e9615b
Showing
3 changed files
with
32 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters