Add validation and documentation for <amp-nested-menu>#25339
Add validation and documentation for <amp-nested-menu>#25339cathyxz merged 6 commits intoampproject:masterfrom
Conversation
|
Hey @ampproject/wg-caching, these files were changed:
|
CrystalOnScript
left a comment
There was a problem hiding this comment.
Overall looking very good and clear! Just a few nits
|
It looks like owners bot is stuck. Could someone from @ampproject/wg-caching take a look? |
|
@cathyxz I'm seeing an error via check links, not owners... |
fcf1cc9 to
1e5d283
Compare
CrystalOnScript
left a comment
There was a problem hiding this comment.
LGTM! Thanks for fixing!
| mandatory_oneof: "['amp-nested-submenu', 'amp-nested-submenu-close', 'amp-nested-submenu-open']" | ||
| } | ||
| } | ||
| tags: { # <amp-nested-menu> <button amp-nested-submenu-open/close> |
There was a problem hiding this comment.
Is there a better way to express this rule?
within
amp-nested-menu, allowed elements can contain either one but not both of these attributes: 'amp-nested-submenu-close', 'amp-nested-submenu-open'
Where allowed elements are: heading tags, buttons, or spans.
Right now, we individually list and specify them, but it would probably be easier if we had one rule and a list of tags to which they applied.
There was a problem hiding this comment.
Yes. Use attr_lists, defined here. Example usage.
Code:
attr_lists {
name: "amp-nested-menu-attrs"
attrs: {
name: "amp-nested-submenu"
mandatory_oneof: "['amp-nested-submenu', 'amp-nested-submenu-close', 'amp-nested-submenu-open']"
}
attrs: {
name: "amp-nested-submenu-close"
mandatory_oneof: "['amp-nested-submenu', 'amp-nested-submenu-close', 'amp-nested-submenu-open']"
}
attrs: {
name: "amp-nested-submenu-open"
mandatory_oneof: "['amp-nested-submenu', 'amp-nested-submenu-close', 'amp-nested-submenu-open']"
}
}
Then for each tag element specify it by name:
tags: {
...
attr_lists: "amp-nested-menu-attrs"
...
}
There was a problem hiding this comment.
And note my code is wrong since the ones below do not have amp-nested-submenu, only the -open and -close
There was a problem hiding this comment.
That saves writing out the individual attributes, but I guess we still have to defined the tags one by one?
There was a problem hiding this comment.
Yes, there are no grouping of TagSpecs which have specific requirements like this on the tag itself. There are grouping of tag names where it serves a specific purpose, like DescendantTagList.
|
@honeybadgerdontcare PTAL? |
|
Thanks a lot for the pointer! Made the change. Let me know if you have further comments. Otherwise I'd like to leave this in a mergeable state by Friday (my last day). |
extensions/amp-nested-menu/validator-amp-nested-menu.protoascii
Outdated
Show resolved
Hide resolved
extensions/amp-nested-menu/validator-amp-nested-menu.protoascii
Outdated
Show resolved
Hide resolved
=( |
honeybadgerdontcare
left a comment
There was a problem hiding this comment.
Ready for merge.
| | <h4 amp-nested-submenu-open></h4> | ||
| | <div amp-nested-submenu></div> | ||
| >> ^~~~~~~~~ | ||
| amp-nested-menu/0.1/test/validator-amp-nested-menu-error.html:59:12 The attribute 'amp-nested-submenu' may not appear in tag 'div'. |
There was a problem hiding this comment.
This is an unfortunate error message since it really should be reporting the issue is it being a descendant of amp-accordion. We should file an issue against the validator on error selection once this is submitted so the issue can point it out.
f4032b6 to
9af4c20
Compare
* cl/279189628 When heights or sizes is empty, the layout should be fixed * cl/279442666 Revision bump for #25339 * Removed unwanted files from pull request
* cl/279189628 When heights or sizes is empty, the layout should be fixed * cl/279442666 Revision bump for ampproject#25339 * Removed unwanted files from pull request
I2I: #25049
Add validation and test files for the
<amp-nested-menu>extension.The following items are enforced via validation:
<amp-sidebar>.layout=fill.<amp-list><amp-accordion><amp-img>amp-nested-submenu: can be applied todiv's only, and cannot be the descendant of<amp-accordion>amp-nested-submenu-open: can be applied todiv,span,buttonor heading tagsamp-nested-submenu-close: same as above/cc @nainar we decided to not support ads for now since according to documentation it's not among the allowed components inside sidebar.
Demo: https://amp-sidebar-nested.firebaseapp.com/