From 802ad9acc05997ed9c2b77aec1a1f32fc550bd65 Mon Sep 17 00:00:00 2001 From: Gabriel Majoulet Date: Thu, 6 Jun 2019 15:13:59 -0400 Subject: [PATCH] Making sure the AMP element is upgraded before calling whenBuilt. (#22724) --- extensions/amp-consent/0.1/consent-ui.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extensions/amp-consent/0.1/consent-ui.js b/extensions/amp-consent/0.1/consent-ui.js index 20b27267496b..eeaee9e32ee6 100644 --- a/extensions/amp-consent/0.1/consent-ui.js +++ b/extensions/amp-consent/0.1/consent-ui.js @@ -24,6 +24,7 @@ import { insertAfterOrAtStart, isAmpElement, removeElement, + whenUpgradedToCustomElement, } from '../../../src/dom'; import {getConsentStateValue} from './consent-info'; import {getData} from '../../../src/event-helper'; @@ -228,7 +229,13 @@ export class ConsentUI { // If the UI is an AMP Element, wait until it's built before showing it, // to avoid race conditions where the UI would be hidden by the runtime // at build time. (see #18841). - isAmpElement(this.ui_) ? this.ui_.whenBuilt().then(() => show()) : show(); + if (isAmpElement(this.ui_)) { + whenUpgradedToCustomElement(this.ui_) + .then(() => this.ui_.whenBuilt()) + .then(() => show()); + } else { + show(); + } } this.isVisible_ = true;