Skip to content

Commit

Permalink
Fix removeAdUnit (prebid#4053)
Browse files Browse the repository at this point in the history
* Fix removeAdUnit

When there are multiple adUnits with the same code, only one of them gets removed. This fixes that.

* snapwich fix
  • Loading branch information
benjaminclot authored and sa1omon committed Nov 28, 2019
1 parent 5cfb75e commit afe1835
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
})
});
};

/**
Expand Down

0 comments on commit afe1835

Please sign in to comment.