Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making sure the consent UI AMP element is upgraded before calling whenBuilt. #22724

Merged
merged 1 commit into from Jun 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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