Skip to content

Commit

Permalink
Core: allow renderers without URLs (#12426)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi authored Nov 9, 2024
1 parent f71023d commit 54a6383
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,15 +635,15 @@ function getPreparedBidForAuction(bid, {index = auctionManager.index} = {}) {
var renderer = null;

// the renderer for the mediaType takes precendence
if (mediaTypeRenderer && mediaTypeRenderer.url && mediaTypeRenderer.render && !(mediaTypeRenderer.backupOnly === true && bid.renderer)) {
if (mediaTypeRenderer && mediaTypeRenderer.render && !(mediaTypeRenderer.backupOnly === true && bid.renderer)) {
renderer = mediaTypeRenderer;
} else if (bidRenderer && bidRenderer.url && bidRenderer.render && !(bidRenderer.backupOnly === true && bid.renderer)) {
} else if (bidRenderer && bidRenderer.render && !(bidRenderer.backupOnly === true && bid.renderer)) {
renderer = bidRenderer;
}

if (renderer) {
// be aware, an adapter could already have installed the bidder, in which case this overwrite's the existing adapter
bid.renderer = Renderer.install({ url: renderer.url, config: renderer.options });// rename options to config, to make it consistent?
bid.renderer = Renderer.install({ url: renderer.url, config: renderer.options, renderNow: renderer.url == null });// rename options to config, to make it consistent?
bid.renderer.setRender(renderer.render);
}

Expand Down
28 changes: 20 additions & 8 deletions test/spec/auctionmanager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1044,26 +1044,38 @@ describe('auctionmanager.js', function () {
Object.entries({
'on adUnit': () => adUnits[0],
'on bid': () => bidderRequests[0].bids[0],
'on mediatype': () => bidderRequests[0].bids[0].mediaTypes.banner,
}).forEach(([t, getObj]) => {
it(t, () => {
let renderer = {
let renderer, bid;
beforeEach(() => {
renderer = {
url: 'renderer.js',
render: (bid) => bid
};
})

let bids1 = Object.assign({},
function getBid() {
let bid = Object.assign({},
bids[0],
{
bidderCode: BIDDER_CODE,
mediaType: 'video-outstream',
mediaType: 'banner',
}
);
Object.assign(getObj(), {renderer});
spec.interpretResponse.returns(bids1);
spec.interpretResponse.returns(bid);
auction.callBids();
const addedBid = auction.getBidsReceived().pop();
assert.equal(addedBid.renderer.url, 'renderer.js');
})
return auction.getBidsReceived().pop();
}

it(t, () => {
expect(getBid().renderer.url).to.eql('renderer.js');
});

it('allows renderers without URL', () => {
delete renderer.url;
expect(getBid().renderer.renderNow).to.be.true;
});
})
})

Expand Down

0 comments on commit 54a6383

Please sign in to comment.