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

Exposing meta tags from attachShadowDoc #22735

Merged
merged 3 commits into from Jun 25, 2019

Conversation

prateekbh
Copy link
Member

fixes #22587

  • need to add more tests

@prateekbh
Copy link
Member Author

@dvoytenko if the approach looks fine, i'll go ahead and add tests around this

src/runtime.js Outdated
@@ -734,13 +734,13 @@ export class MultidocManager {
dev().fine(TAG, '- set title: ', shadowRoot.AMP.title);
break;
case 'META':
shadowRoot.AMP.meta = shadowRoot.AMP.meta || [];
Copy link
Contributor

Choose a reason for hiding this comment

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

I really feel like we should just simply do:

shadowRoot.AMP.head = doc.head

This would let publishers to just do head.querySelector('meta[name=X]') and all that stuff.

Copy link
Member Author

Choose a reason for hiding this comment

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

nit: I see that [shadowRoot.ampdoc.getHeadNode().children]( https://github.com/ampproject/amphtml/issues/22587#issuecomment-497877987) gives a filtered subset of the actual head.

Would this create like a conflict with the same? Or create confusion for publishers as to choose which one?

Copy link
Contributor

Choose a reason for hiding this comment

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

It shouldn't. Because the ampdoc is not really in the user-space APIs - it's intended for the runtime uses specifically. And likely will be obfuscated soon. The returned AMP object, however, we can shape as we want.

Copy link

Choose a reason for hiding this comment

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

I'm trying to understand why this is different from the next case for "LINK" tags where they are automatically appended to the document's head.
Can it do the same for meta tags or is there a reason why not to do it from here?

Copy link

Choose a reason for hiding this comment

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

I really feel like we should just simply do:

shadowRoot.AMP.head = doc.head

This would let publishers to just do head.querySelector('meta[name=X]') and all that stuff.

@dvoytenko regarding your suggestion, publishers can currently do exactly this by querying the original doc before passing it to attachShadowDoc so I don't see the big enhancement by adding it to the AMP object unless for future updates to remove the requirement of passing a doc (AMP will make the call. Wishful thinking :)).

So, I think it will be more useful to do the full job by appending it directly to head (see my other comment) or attaching it as an array so no need to query anything.

But, as said, it's really up to you guys to decide.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Joelsz the big benefit should come from attachShadowDocAsStream, where the document is streamed.

@prateekbh prateekbh requested a review from dvoytenko June 13, 2019 16:50
@prateekbh prateekbh changed the title [WIP] exposing meta tags from attachShadowDoc Exposing meta tags from attachShadowDoc Jun 25, 2019
@prateekbh prateekbh merged commit 2fc25dc into ampproject:master Jun 25, 2019
@prateekbh prateekbh deleted the amp-shadow-meta branch June 25, 2019 20:38
thekorn pushed a commit to edelight/amphtml that referenced this pull request Sep 11, 2019
* exposing meta tags from attachShadowDoc

* exposes doc head via attachDoc in shadow mode

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

Successfully merging this pull request may close these issues.

Handle meta tags from AMP to the PWA when used as data source
4 participants