Skip to content

Commit

Permalink
Making sure the AMP element is upgraded before calling whenBuilt. (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
gmajoulet committed Jun 6, 2019
1 parent d72c3f8 commit 802ad9a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion extensions/amp-consent/0.1/consent-ui.js
Expand Up @@ -24,6 +24,7 @@ import {
insertAfterOrAtStart,
isAmpElement,
removeElement,
whenUpgradedToCustomElement,
} from '../../../src/dom';
import {getConsentStateValue} from './consent-info';
import {getData} from '../../../src/event-helper';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 802ad9a

Please sign in to comment.