Skip to content

Commit

Permalink
check amp-ad iframe_ is null (#3670)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouyx committed Jun 21, 2016
1 parent b3098a6 commit 19173c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions extensions/amp-ad/0.1/amp-ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ class AmpAd extends AMP.BaseElement {
}, /* opt_is3P */ true);
this.iframe_.style.visibility = 'hidden';
listenForOnce(this.iframe_, 'render-start', () => {
if (!this.iframe_) {
return;
}
this.iframe_.style.visibility = '';
this.sendEmbedInfo_(this.isInViewport());
}, /* opt_is3P */ true);
Expand Down Expand Up @@ -372,13 +375,20 @@ class AmpAd extends AMP.BaseElement {
* @private
*/
noContentHandler_() {
// If iframe is null nothing to do.
if (!this.iframe_) {
return;
}
// If a fallback does not exist attempt to collapse the ad.
if (!this.fallback_) {
this.attemptChangeHeight(0, () => {
this.element.style.display = 'none';
});
}
this.deferMutate(() => {
if (!this.iframe_) {
return;
}
if (this.fallback_) {
// Hide placeholder when falling back.
if (this.placeholder_) {
Expand Down

0 comments on commit 19173c1

Please sign in to comment.