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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Move ampDoc references into amp-story buildCallback #30986

Merged
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
28 changes: 17 additions & 11 deletions extensions/amp-story/1.0/amp-story.js
Expand Up @@ -327,13 +327,14 @@ export class AmpStory extends AMP.BaseElement {
/** @private @const {!../../../src/service/platform-impl.Platform} */
this.platform_ = Services.platformFor(this.win);

/** @private @const {!../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = Services.viewerForDoc(this.element);
/** @private {?../../../src/service/viewer-interface.ViewerInterface} */
this.viewer_ = null;

/** @private @const {?AmpStoryViewerMessagingHandler} */
this.viewerMessagingHandler_ = this.viewer_.isEmbedded()
? new AmpStoryViewerMessagingHandler(this.win, this.viewer_)
: null;
/** @private {?AmpStoryViewerMessagingHandler} */
this.viewerMessagingHandler_ = null;

/** @private {?../../../src/service/localization.LocalizationService} */
this.localizationService_ = null;

/**
* Store the current paused state, to make sure the story does not play on
Expand All @@ -353,8 +354,16 @@ export class AmpStory extends AMP.BaseElement {

/** @private {?LiveStoryManager} */
this.liveStoryManager_ = null;
}

/** @override */
buildCallback() {
this.viewer_ = Services.viewerForDoc(this.element);

this.viewerMessagingHandler_ = this.viewer_.isEmbedded()
? new AmpStoryViewerMessagingHandler(this.win, this.viewer_)
: null;

/** @private @const {!../../../src/service/localization.LocalizationService} */
this.localizationService_ = getLocalizationService(this.element);

this.localizationService_
Expand Down Expand Up @@ -389,10 +398,7 @@ export class AmpStory extends AMP.BaseElement {
'en-xa',
enXaPseudoLocaleBundle
);
}

/** @override */
buildCallback() {
if (this.isStandalone_()) {
this.initializeStandaloneStory_();
}
Expand Down Expand Up @@ -1003,7 +1009,7 @@ export class AmpStory extends AMP.BaseElement {
// Preloads and prerenders the share menu.
this.shareMenu_.build();

const infoDialog = shouldShowStoryUrlInfo(this.viewer_)
const infoDialog = shouldShowStoryUrlInfo(devAssert(this.viewer_))
? new InfoDialog(this.win, this.element)
: null;
if (infoDialog) {
Expand Down