From acb01620c02152b3c079b53e5893add865b960a7 Mon Sep 17 00:00:00 2001 From: Gleb Glushtsov Date: Mon, 17 Jun 2019 14:24:04 -0400 Subject: [PATCH] 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}`);