Skip to content

Commit

Permalink
Inject creativeComment after render so it sticks around
Browse files Browse the repository at this point in the history
  • Loading branch information
jsut committed May 27, 2021
1 parent f2befaa commit 38843b6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id, options) {
const {height, width, ad, mediaType, adUrl, renderer} = bid;

const creativeComment = document.createComment(`Creative ${bid.creativeId} served by ${bid.bidder} Prebid.js Header Bidding`);
utils.insertElement(creativeComment, doc, 'body');

if (isRendererRequired(renderer)) {
executeRenderer(renderer, bid);
utils.insertElement(creativeComment, doc, 'html');
} else if ((doc === document && !utils.inIframe()) || mediaType === 'video') {
const message = `Error trying to write ad. Ad render call ad id ${id} was prevented from writing to the main document.`;
emitAdRenderFail({reason: PREVENT_WRITING_ON_MAIN_DOCUMENT, message, bid, id});
Expand All @@ -443,6 +443,7 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id, options) {
doc.write(ad);
doc.close();
setRenderSize(doc, width, height);
utils.insertElement(creativeComment, doc, 'html');
utils.callBurl(bid);
} else if (adUrl) {
const iframe = utils.createInvisibleIframe();
Expand All @@ -454,6 +455,7 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id, options) {

utils.insertElement(iframe, doc, 'body');
setRenderSize(doc, width, height);
utils.insertElement(creativeComment, doc, 'html');
utils.callBurl(bid);
} else {
const message = `Error trying to write ad. No ad for bid response id: ${id}`;
Expand Down

0 comments on commit 38843b6

Please sign in to comment.