Skip to content

Commit

Permalink
do not use Array.find()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gleb Glushtsov committed Jun 17, 2019
1 parent 6c097ff commit acb0162
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down

0 comments on commit acb0162

Please sign in to comment.