Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: allow renderers without URLs #12426

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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