-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
✨ [amp-list] Introduce "amp-state:" as a usable protocol for the src attribute. #26284
Conversation
This pull request introduces 1 alert when merging dedd3fd into 5bfb0e5 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 6778b02 into b338300 - view on LGTM.com new alerts:
|
72f74be
to
2a33705
Compare
After discussions with @choumx, I've loosened up this implementation to allow for usage of the Note that this does create a potentially confusing situation where any async-created amp-state would not be present for the amp-list initialization. For example:
|
4ca6138
to
9d3ecdb
Compare
I was curious if hyphens were allowed in URI schemes and looks like they are:
|
There was a a failing percy test, but after a rerun it passed. |
f0af028
to
4ac091a
Compare
I'm going to chase this case in a followup pr. It probably makes sense to have |
@ampproject/wg-ui-and-a11y Any opinions on adding this feature in amp-list-0.1 vs. a new version? |
Why would this be an issue? I don't think anything here breaks backwards compatibility. |
This could be a good chance to clean up the API/code and also offer a carrot for adoption. |
To be clear, I think this PR is fine to merge as is-is. We can discuss more before actual launch. |
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.
Looking good. Can we add an example test case to examples/bind/list.amp.html
?
Also in case you were wondering, that file should probably live in test/manual/
(no action required).
extensions/amp-list/0.1/amp-list.js
Outdated
const errorMsg = | ||
'You must include amp-bind in order to use amp-state as an initial source for amp-list.'; | ||
user().error(TAG, errorMsg); | ||
return Promise.resolve(); |
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.
fetchList_()
catches network fetch errors to perform fallback behaviors e.g. showing a [fallback]
element if it exists. We should probably do the same here, which makes userAssert
above a reasonable option.
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.
Hmm. This actually makes it more similar to fetchList_
than to the flow of rendering computed bind expressions (which don't have a fallback). Considering the async nature of the state retrieval, I'll merge it with fetchList_
Thank you for the thoughtful feedback @choumx! I'll try to address all your comments |
709c945
to
be5a1fc
Compare
a85bfc2
to
21d49e3
Compare
In a followup PR I'll still need to ensure that |
…fetch than to synchronous local data
cfeeca2
to
09fdd96
Compare
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.
Thanks for updating!
…frame-pymjs-support * 'master' of github.com:ampproject/amphtml: (436 commits) 🐛Add computed styles to fake win (ampproject#26514) 📦 Update dependency eslint-config-prettier to v6.10.0 (ampproject#26518) 🐛 Rewrite relative urls in the bookend (ampproject#26490) ✨ [amp-list] Introduce "amp-state:" as a usable protocol for the src attribute. (ampproject#26284) Add terminal newline to files.txt (ampproject#26513) 📦 Update dependency chromedriver to v79.0.2 (ampproject#26515) ♻️ Change the opt-in cookie values to reflect upcoming CDN changes (ampproject#26489) ♻️<amp-next-page> v2 minor renaming and fixes (ampproject#26468) fix link (ampproject#26508) amp-list: fix broken test re. missing layout (ampproject#26509) performance: emit timeOrigin w/ polyfill (ampproject#26485) Position n+1 story desktop page before positioning attributes are set. (ampproject#26488) ✨amp-nested-menu: allow svg into (ampproject#26502) Log user warning when missing URL arg for shadow doc (ampproject#26290) 📦 Update dependency puppeteer to v2.1.0 (ampproject#26501) Ensure that fluid slots hidden by media queries do not issue ad requests. (ampproject#26352) 📦 Update dependency mocha to v7.0.1 (ampproject#26495) 📦 Update dependency fetch-mock to v8.3.2 (ampproject#26491) Revert 'Move mutator implementations out to a standalone service' (ampproject#26479) Fix syntax error (ampproject#26481) ...
Summary
Implements #15647.
Allows an amp-list to initialize off of an SSRed amp-state. Initially I had been worried that this would delay the rendering of
amp-list
untilamp-bind
had finished initialization (ironically this could be slower than the client side fetch would have been). Turns out though, thatamp-state
parsing andgetState
are not blocked on amp-bind'sinitializationPromise
, so all is well.I've gated it on a feature flag, so nobody should be able to use it yet. In a followup PR I'll run performance measurements, create documentation and remove the flag.
cc @jridgewell / @choumx