Skip to content
Permalink
Browse files

FIX: handle no ad size given for AdSense and DFP ad units

For AdSense, assume responsive size.
For DFP, don't attempt to render the ad unit.
  • Loading branch information...
nlalonde committed Sep 10, 2019
1 parent 2ad24e4 commit 62888e734fcbb2d8c5a1ccf5793358412b749643
@@ -14,14 +14,24 @@ function parseAdWidth(value) {
if (value === "responsive") {
return "auto";
}
return `${parseInt(value.substring(0, 3).trim())}px`;
const w = parseInt(value.substring(0, 3).trim());
if (isNaN(w)) {
return "auto";
} else {
return `${w}px`;
}
}

function parseAdHeight(value) {
if (value === "responsive") {
return "auto";
}
return `${parseInt(value.substring(4, 7).trim())}px`;
const h = parseInt(value.substring(4, 7).trim());
if (isNaN(h)) {
return "auto";
} else {
return `${h}px`;
}
}

function loadAdsense() {
@@ -126,10 +126,14 @@ function getWidthAndHeight(placement, settings, isMobile) {
renderCounts[placement] += 1;
}

return {
const sizeObj = {
width: parseInt(splitWidthInt(size)),
height: parseInt(splitHeightInt(size))
};

if (!isNaN(sizeObj.width) && !isNaN(sizeObj.height)) {
return sizeObj;
}
}

function defineSlot(
@@ -290,21 +294,24 @@ export default AdComponent.extend({
"showToTrustLevel",
"showToGroups",
"showAfterPost",
"showOnCurrentPage"
"showOnCurrentPage",
"size"
)
showAd(
publisherId,
showToTrustLevel,
showToGroups,
showAfterPost,
showOnCurrentPage
showOnCurrentPage,
size
) {
return (
publisherId &&
showToTrustLevel &&
showToGroups &&
showAfterPost &&
showOnCurrentPage
showOnCurrentPage &&
size
);
},

0 comments on commit 62888e7

Please sign in to comment.
You can’t perform that action at this time.