From acb01620c02152b3c079b53e5893add865b960a7 Mon Sep 17 00:00:00 2001 From: Gleb Glushtsov Date: Mon, 17 Jun 2019 14:24:04 -0400 Subject: [PATCH 1/4] do not use Array.find() --- modules/33acrossBidAdapter.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 3f7dcb50028..6457838dd45 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -38,10 +38,18 @@ function _getViewability(element, topWin, { w, h } = {}) { function _mapAdUnitPathToElementId(adUnitCode) { if (utils.isGptPubadsDefined()) { + const adSlots = googletag.pubads().getSlots(); const isMatchingAdSlot = utils.isSlotMatchingAdUnitCode(adUnitCode); - const matchingAdSlot = window.googletag.pubads().getSlots().find(isMatchingAdSlot); + let matchingAdSlot = null; - if (matchingAdSlot) { + for (let i = 0; i < adSlots.length; i++) { + if (isMatchingAdSlot(adSlots[i])) { + matchingAdSlot = adSlots[i] + break; + } + } + + if (matchingAdSlot !== null) { const id = matchingAdSlot.getSlotElementId(); utils.logInfo(`[33Across Adapter] Map ad unit path to HTML element id: '${adUnitCode}' -> ${id}`); From c2cb54d5fb4845875ad92d3b99746dea5fe6b184 Mon Sep 17 00:00:00 2001 From: Gleb Glushtsov Date: Tue, 18 Jun 2019 10:56:35 -0400 Subject: [PATCH 2/4] return id once element is found --- modules/33acrossBidAdapter.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 6457838dd45..5a308498981 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -40,21 +40,16 @@ function _mapAdUnitPathToElementId(adUnitCode) { if (utils.isGptPubadsDefined()) { const adSlots = googletag.pubads().getSlots(); const isMatchingAdSlot = utils.isSlotMatchingAdUnitCode(adUnitCode); - let matchingAdSlot = null; + let id; for (let i = 0; i < adSlots.length; i++) { if (isMatchingAdSlot(adSlots[i])) { - matchingAdSlot = adSlots[i] - break; - } - } + id = adSlots[i].getSlotElementId(); - if (matchingAdSlot !== null) { - const id = matchingAdSlot.getSlotElementId(); + utils.logInfo(`[33Across Adapter] Map ad unit path to HTML element id: '${adUnitCode}' -> ${id}`); - utils.logInfo(`[33Across Adapter] Map ad unit path to HTML element id: '${adUnitCode}' -> ${id}`); - - return id; + return id; + } } } From 5bcde42b608f80202cd727825f7085009452b2dd Mon Sep 17 00:00:00 2001 From: Gleb Glushtsov Date: Tue, 18 Jun 2019 11:00:41 -0400 Subject: [PATCH 3/4] return id once element is found --- modules/33acrossBidAdapter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 5a308498981..9524b773660 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -40,11 +40,10 @@ function _mapAdUnitPathToElementId(adUnitCode) { if (utils.isGptPubadsDefined()) { const adSlots = googletag.pubads().getSlots(); const isMatchingAdSlot = utils.isSlotMatchingAdUnitCode(adUnitCode); - let id; for (let i = 0; i < adSlots.length; i++) { if (isMatchingAdSlot(adSlots[i])) { - id = adSlots[i].getSlotElementId(); + let id = adSlots[i].getSlotElementId(); utils.logInfo(`[33Across Adapter] Map ad unit path to HTML element id: '${adUnitCode}' -> ${id}`); From a72b1a0a7612ef4e482f088ba7fcaefdd8f33945 Mon Sep 17 00:00:00 2001 From: Gleb Glushtsov Date: Tue, 18 Jun 2019 11:17:29 -0400 Subject: [PATCH 4/4] let -> const --- modules/33acrossBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 9524b773660..801a5d564a3 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -43,7 +43,7 @@ function _mapAdUnitPathToElementId(adUnitCode) { for (let i = 0; i < adSlots.length; i++) { if (isMatchingAdSlot(adSlots[i])) { - let id = adSlots[i].getSlotElementId(); + const id = adSlots[i].getSlotElementId(); utils.logInfo(`[33Across Adapter] Map ad unit path to HTML element id: '${adUnitCode}' -> ${id}`);