From 18c5a00298dd800626df73f1ae050f039fbaf916 Mon Sep 17 00:00:00 2001 From: vkim Date: Mon, 4 Nov 2019 15:01:29 -0500 Subject: [PATCH] do not select element that gets removed after dfp render --- src/secureCreatives.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/secureCreatives.js b/src/secureCreatives.js index df7abe4ebee..7584c5d2bf7 100644 --- a/src/secureCreatives.js +++ b/src/secureCreatives.js @@ -81,8 +81,9 @@ export function _sendAdToCreative(adObject, remoteDomain, source) { function resizeRemoteCreative({ adUnitCode, width, height }) { // resize both container div + iframe - ['div:last-child', 'div:last-child iframe'].forEach(elmType => { - let element = getElementByAdUnit(elmType); + ['div', 'iframe'].forEach(elmType => { + // not select element that gets removed after dfp render + let element = getElementByAdUnit(elmType + ':not([style*="display: none"])'); if (element) { let elementStyle = element.style; elementStyle.width = width + 'px';