From a0ad27ecde71b8677c8dbea6ed54e1d388fee8bd Mon Sep 17 00:00:00 2001 From: Benjamin Clot Date: Fri, 2 Aug 2019 11:14:26 +0200 Subject: [PATCH 1/2] Fix removeAdUnit When there are multiple adUnits with the same code, only one of them gets removed. This fixes that. --- src/prebid.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/prebid.js b/src/prebid.js index 90f6365585e..b17d654747a 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -389,13 +389,8 @@ $$PREBID_GLOBAL$$.removeAdUnit = function (adUnitCode) { adUnitCodes = [adUnitCode]; } - adUnitCodes.forEach((adUnitCode) => { - for (let i = 0; i < $$PREBID_GLOBAL$$.adUnits.length; i++) { - if ($$PREBID_GLOBAL$$.adUnits[i].code === adUnitCode) { - $$PREBID_GLOBAL$$.adUnits.splice(i, 1); - } - } - }) + $$PREBID_GLOBAL$$.adUnits = $$PREBID_GLOBAL$$.adUnits + .filter(adUnit => adUnitCodes.indexOf(adUnit.code) === -1); }; /** From ae3c548a0d2b00e8c7e75f6e50b1fb2acf747265 Mon Sep 17 00:00:00 2001 From: Benjamin Clot Date: Thu, 8 Aug 2019 10:54:34 +0200 Subject: [PATCH 2/2] snapwich fix --- src/prebid.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/prebid.js b/src/prebid.js index b17d654747a..efa1198d36c 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -389,8 +389,13 @@ $$PREBID_GLOBAL$$.removeAdUnit = function (adUnitCode) { adUnitCodes = [adUnitCode]; } - $$PREBID_GLOBAL$$.adUnits = $$PREBID_GLOBAL$$.adUnits - .filter(adUnit => adUnitCodes.indexOf(adUnit.code) === -1); + adUnitCodes.forEach((adUnitCode) => { + for (let i = $$PREBID_GLOBAL$$.adUnits.length - 1; i >= 0; i--) { + if ($$PREBID_GLOBAL$$.adUnits[i].code === adUnitCode) { + $$PREBID_GLOBAL$$.adUnits.splice(i, 1); + } + } + }); }; /**