From afe18355a9672251bc5c3002caed21bf7d13c438 Mon Sep 17 00:00:00 2001 From: Benjamin Clot Date: Fri, 9 Aug 2019 05:02:12 +0200 Subject: [PATCH] Fix removeAdUnit (#4053) * Fix removeAdUnit When there are multiple adUnits with the same code, only one of them gets removed. This fixes that. * snapwich fix --- src/prebid.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/prebid.js b/src/prebid.js index 90f6365585e..efa1198d36c 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -390,12 +390,12 @@ $$PREBID_GLOBAL$$.removeAdUnit = function (adUnitCode) { } adUnitCodes.forEach((adUnitCode) => { - for (let i = 0; i < $$PREBID_GLOBAL$$.adUnits.length; i++) { + for (let i = $$PREBID_GLOBAL$$.adUnits.length - 1; i >= 0; i--) { if ($$PREBID_GLOBAL$$.adUnits[i].code === adUnitCode) { $$PREBID_GLOBAL$$.adUnits.splice(i, 1); } } - }) + }); }; /**