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

amp-list load-more validation #20094

Merged
merged 5 commits into from Jan 14, 2019
Merged

Conversation

cathyxz
Copy link
Contributor

@cathyxz cathyxz commented Dec 27, 2018

DO NOT MERGE THIS UNTIL INFINITE SCROLL IS READY TO LAUNCH.

The documentation for amp-list load-more is #19967.

  1. Introducing load-more and load-more-bookmark as attributes on amp-list.
  2. Allowing child elements in amp-list to contain elements containing load-more-loading, load-more-failed, load-more-button, load-more-end.

To Reviewers: please take a look at the comment regarding the children with attributes and let me know if there's a better way or more precise validation rule that we should use.

@@ -94,6 +105,33 @@ tags: { # <amp-list> with mandatory src and/or [src] attr
supported_layouts: RESPONSIVE
}
}
tags: { # amp-list load-more children
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically amp-list with load-more should be allowed to have up to 4 div children, each containing one of these attributes. These attributes should be mutually exclusive, and there should only be at most one div containing each attribute. If there's a better way to "validate" that, I'd love to know. Otherwise, I'll just write some JS asserts in the source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the alternative here is to define a reference point for amp list [load-more] and have that be a mandatory parent, but I'm not sure where we are on the usage of reference points discussion (the last I heard we are refactoring / changing the way we use them?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, per our conversation in #19967, it's highly likely that we would like to allow this to be any element, not just a <div>. Is there better way to validate this without whitelisting all the allowed tags here, or introducing reference points?

Copy link
Contributor

Choose a reason for hiding this comment

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

You could add these attributes to $GLOBALS and they would be allowed on any element. Then requires_extension could be added to them to ensure that AMP-LIST is included as a script tag. However, the requirement of having the parent be amp-list is then lost as that's not possible to put in an attribute spec since it really only applies to tags. Further they could then also be put on the <amp-list> element and I'm not sure what that would even mean.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it does move to being on any element I'd suggest making the attribute name more explicit about amp-list, e.g. amp-list-load-more-button.

Copy link
Contributor

Choose a reason for hiding this comment

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

That wasn't my suggestion. I suggested making a new tag spec with the tag being amp-list-load-more.

Copy link
Contributor Author

@cathyxz cathyxz Jan 3, 2019

Choose a reason for hiding this comment

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

Apologies I misunderstood. Please allow me to clarify: as in literally creating a new tag called <amp-list-load-more>?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome. That does seem like the ideal solution. Especially since that will also let us cleanly whitelist which children we want to allow in these elements. Thanks a lot @honeybadgerdontcare for the offline followup as well!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done.

@@ -86,6 +86,32 @@
src="https://data.com/articles.json?ref=CANONICAL_URL"
auto-resize>
<div></div>
<!-- Valid amp-list with load-more="auto" attribute -->
<amp-list width=10 height=10
Copy link
Contributor

Choose a reason for hiding this comment

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

valid test case with just load-more for the default case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So even though I have not programmatically enforced this, I think the conclusion of the discussion on https://github.com/ampproject/amphtml/pull/19967/files#diff-4154928399fad29a55f4c6450302eef6R300 is that we should only have auto or manual, and remove the default option to avoid confusion. @CrystalFaith @andrewwatterson please keep me honest. xD

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@cathyxz
Copy link
Contributor Author

cathyxz commented Jan 10, 2019

@honeybadgerdontcare made the changes you requested. Could you PTAL? =)

@cathyxz cathyxz changed the title [DO NOT MERGE] amp-list load-more validation amp-list load-more validation Jan 10, 2019
@cathyxz cathyxz removed the Blocked label Jan 10, 2019
@honeybadgerdontcare
Copy link
Contributor

I see the reference points, is that the final form? Didn't you want to make the attributes unique on an element (e.g. load-more-end and load-more-failed can't be on the same element):

mandatory_oneof: "['load-more-button', 'load-more-end', 'load-more-failed', 'load-more-loading']"

@cathyxz
Copy link
Contributor Author

cathyxz commented Jan 10, 2019

Oops, this is embarrassing. I jumped the gun a little. My push failed on the pre-submit check.

Copy link
Contributor

@honeybadgerdontcare honeybadgerdontcare left a comment

Choose a reason for hiding this comment

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

lgtm!

@cathyxz cathyxz merged commit 5b08c28 into ampproject:master Jan 14, 2019
@cathyxz cathyxz deleted the validation/list branch January 14, 2019 19:20
twifkak added a commit to twifkak/amphtml that referenced this pull request Jan 16, 2019
@twifkak twifkak mentioned this pull request Jan 16, 2019
twifkak added a commit to twifkak/amphtml that referenced this pull request Jan 16, 2019
twifkak added a commit that referenced this pull request Jan 16, 2019
* cl/229240741 Allow target attribute on form[method=POST] for ACTIONS

* cl/229285760 Revision bump for #20094

* cl/229285815 Revision bump for #20322

* cl/229408305 Validate "transformer" type identifier value.

* cl/229425442 Revision bump for #20330

* cl/229435530 Include version of transformers used in ValidationResult
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* Add basic validation for amp-list without element customization

* Add validation for amp-list children attributes

* Create tag_spec

* Remove reference points in favor of new tag

* Add mandatory exclusion
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* cl/229240741 Allow target attribute on form[method=POST] for ACTIONS

* cl/229285760 Revision bump for ampproject#20094

* cl/229285815 Revision bump for ampproject#20322

* cl/229408305 Validate "transformer" type identifier value.

* cl/229425442 Revision bump for ampproject#20330

* cl/229435530 Include version of transformers used in ValidationResult
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.

None yet

6 participants