这是indexloc提供的服务,不要输入任何密码
Skip to content

🐛 [Story attachments] Fix attachment Firebase demos #37335

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

Merged
merged 9 commits into from
Jan 11, 2022

Conversation

mszylkowski
Copy link
Contributor

Allows the page-attachment and share-menus to be imported inline in the document on example stories so that the extensions load on Firebase.

There's a bug where extensionsFor.installExtensionForDoc doesn't point to the right URL for the extension on Firebase demos (it points to a URL with rtv, but it should point to the dist/ url).

Relies on upgradeCallback, which on the documentation says: "This method is called when the element is added to DOM for the first time and before buildCallback to give the element a chance to redirect its implementation to another BaseElement implementation. The returned value can be either null or undefined to indicate that no redirection will take place; BaseElement instance to upgrade immediately; or a promise to upgrade with the resolved BaseElement instance."

Alternatives

An alternative can be to directly change the upgradeCallback of page-attachment and share-menu to return a promise:

// amp-story-page-attachment.js

upgradeCallback() {
    const storyEl = closestAncestorBySelector("amp-story");
    return whenUpgradedToCustomElement(storyEl)
        .then(() => storyEl.getImpl())
        .then(() => null);
}

However, this requires all the different classes to have more repeated code.

Another alternative is to do #37331 but it's harder to follow the promise chains.

@amp-owners-bot
Copy link

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

extensions/amp-story-page-attachment/0.1/amp-story-page-attachment.js
extensions/amp-story-share-menu/0.1/amp-story-share-menu.js
extensions/amp-story/1.0/utils.js

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

Successfully merging this pull request may close these issues.

2 participants