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

Conversation

processprocess
Copy link
Contributor

The code tries to access the ampdoc before it's available and everything fails. This is caused by the service getters in amp-story.constructor() that use this.element as a parameter. The ones using this.win are fine.
These service getters need to be moved to amp-story.buildCallback().
#30798 (comment)

context / fixes #30798

@amp-owners-bot
Copy link

amp-owners-bot bot commented Nov 3, 2020

Hey @gmajoulet, @newmuis, @Enriqe! These files were changed:

extensions/amp-story/1.0/amp-story.js

Copy link
Contributor

@gmajoulet gmajoulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending the one comment

@@ -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 = this.viewer_ && shouldShowStoryUrlInfo(this.viewer_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The viewer should always be defined at this point. This is dangerous because it means that infoDialog would be false if the viewer is not defined, without any error message. If you want to satisfy the compiler, please use devAssert().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

devAssert() is making sense now. Thanks Gabriel!

@processprocess processprocess merged commit 375fad8 into ampproject:master Nov 4, 2020
@processprocess processprocess deleted the ampdoc-buildcallback branch November 4, 2020 18:25
ed-bird pushed a commit to ed-bird/amphtml that referenced this pull request Dec 10, 2020
* Move methods that need ampdoc to buildCallback.

* Update types.

* Remove const

* Fix typo.

* devAssert.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[amp-story] No ampdoc found for [object HTMLElement]
3 participants