-
Notifications
You must be signed in to change notification settings - Fork 813
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
Map Block AMP Compatibility Alternate Approach #13405
Conversation
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: December 3, 2019. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a clever approach! It should work well when the map blocks are inside of post_content
. Checks need to be added for when this is not the case, however (e.g. on archive templates that use the_content()
). Also, I suppose the block will just have to show nothing when it is being rendered outside of post content, e.g. sidebar, header, footer?
e651d6f
to
89cd41a
Compare
@westonruter the iframe sizing should be resolved in 3a0a117 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review, this one kinda fell through the cracks.
…ML page with nothing but the block. For AMP requests, render an iFrame with the special URL as src.
…lay on non-single pages.
dd6f3fd
to
d9492d1
Compare
Rebased. |
Caution: This PR has changes that must be merged to WordPress.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work well overall, but I'm getting the following JS error when viewing maps on non-AMP views now:
mapbox-gl.1382b28d502145eaee66.js:formatted:28909 Uncaught TypeError: Cannot read property 'off' of undefined
at Fi.onRemove (mapbox-gl.1382b28d502145eaee66.js:formatted:28909)
at n.removeControl (mapbox-gl.1382b28d502145eaee66.js:formatted:28172)
at t.setBoundsByMarkers (view.js?ver=1574345509:1)
at view.js?ver=1574345509:1
at e (lodash.min.js?ver=4.17.15:68)
at o (lodash.min.js?ver=4.17.15:68)
at i (lodash.min.js?ver=4.17.15:68)
Fi.onRemove @ mapbox-gl.1382b28d502145eaee66.js:formatted:28909
n.removeControl @ mapbox-gl.1382b28d502145eaee66.js:formatted:28172
(anonymous) @ view.js?ver=1574345509:1
(anonymous) @ view.js?ver=1574345509:1
e @ lodash.min.js?ver=4.17.15:68
o @ lodash.min.js?ver=4.17.15:68
i @ lodash.min.js?ver=4.17.15:68
setTimeout (async)
bo @ lodash.min.js?ver=4.17.15:85
f @ lodash.min.js?ver=4.17.15:69
Do you get that one too?
Hmmm I'm not getting that. Is it possible to take a look at the exact map in question? |
I can't seem to reproduce anymore, with the same map I used yesterday. ¯_(ツ)_/¯ |
* 8.0 Release: running changelog * Changelog: add #13921 * Changelog: add #13980 * Changelog: add #13905 * Changelog: add #13971 * Changelog: add #13984 * Changelog: add #14009 * Changelog: add #13620 * Remove things that will ship in 7.9.1 * Changelog: add 7.9.1 release (#14044) * Changelog: add base for 7.9.1 release * Update release date and post link * Changelog: add #14066 * Update changelog for 7.9.1 * Changelog: add #13405 * Changelog: add #13841 * Changelog: add #13924 * Changelog: add #13986 * Changelog: add #14010, #14028, #14053, #14055. * Changelog: add #14054 * Changelog: add #14031 * Changelog: add #14039 * Changelog: add #14050 * Changelog: add #14070 * Changelog: add #14082 * Changelog: add #14084 * Changelog: add #14111 * Changelog: add #13961 * Changelog: add #14047 * Changelog: add #14091 * Changelog: add #14108 * Changelog: add #14121
r202026-wpcom |
Changes proposed in this Pull Request:
This PR is an alternate approach to #13321, which came about due to problems described in #13321 (comment). In this approach, a URL param (
map-block-counter
) will cause page requests to render a complete document containing only a single Map block. The value ofmap-block-counter
determines the ordinal of the block to render. If no block at the provided value is found, the page renders normally. In AMP requests, Map block will render as an iFrame using the special URL as thesrc
. This approach replaces thesrcdoc
attribute and length/browser compatibility constraints associated with it.DOMDocument
is used to extract the desired block markup from the post content.TODO:
Is this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
src
of theamp-iframe
s. Load these URLs in separate browser windows. Make sure they render correctly.map-block-post-id
and/ormap-block-counter
query params. This should cause the full page to load rather than the block alone.Proposed changelog entry for your changes: