Skip to content

Commit

Permalink
Add validation for amp-list children attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
cathyxz committed Dec 27, 2018
1 parent 54f94c8 commit c108935
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 7 deletions.
16 changes: 16 additions & 0 deletions extensions/amp-list/0.1/test/validator-amp-list.html
Expand Up @@ -102,6 +102,17 @@
load-more="manual"
load-more-bookmark="next"></amp-list>
</amp-list>
<!-- Valid amp-list with custom children -->
<amp-list width=10 height=10
src="https://data.com/articles.json?ref=CANONICAL_URL"
load-more="manual"
load-more-bookmark="next">
<div load-more-button></div>
<div load-more-loading></div>
<div load-more-failed></div>
<div load-more-end></div>
</amp-list>
</amp-list>
<!-- Invalid: unsupported "binding" attribute value -->
<amp-list width=10 height=10
src="https://data.com/articles.json?ref=CANONICAL_URL"
Expand Down Expand Up @@ -133,5 +144,10 @@
load-more="gibberish"
load-more-bookmark="next"></amp-list>
</amp-list>
<!-- Invalid load-more attributes -->
<div load-more-button></div>
<div load-more-loading></div>
<div load-more-failed></div>
<div load-more-end></div>
</body>
</html>
38 changes: 31 additions & 7 deletions extensions/amp-list/0.1/test/validator-amp-list.out
Expand Up @@ -107,48 +107,72 @@ amp-list/0.1/test/validator-amp-list.html:85:2 The attribute 'auto-resize' in ta
| load-more="manual"
| load-more-bookmark="next"></amp-list>
| </amp-list>
| <!-- Valid amp-list with custom children -->
| <amp-list width=10 height=10
| src="https://data.com/articles.json?ref=CANONICAL_URL"
| load-more="manual"
| load-more-bookmark="next">
| <div load-more-button></div>
| <div load-more-loading></div>
| <div load-more-failed></div>
| <div load-more-end></div>
| </amp-list>
| </amp-list>
| <!-- Invalid: unsupported "binding" attribute value -->
| <amp-list width=10 height=10
>> ^~~~~~~~~
amp-list/0.1/test/validator-amp-list.html:106:2 The attribute 'binding' in tag 'amp-list' is set to the invalid value 'this-is-an-error'. (see https://www.ampproject.org/docs/reference/components/amp-list) [DISALLOWED_HTML]
amp-list/0.1/test/validator-amp-list.html:117:2 The attribute 'binding' in tag 'amp-list' is set to the invalid value 'this-is-an-error'. (see https://www.ampproject.org/docs/reference/components/amp-list) [DISALLOWED_HTML]
| src="https://data.com/articles.json?ref=CANONICAL_URL"
| binding="this-is-an-error">
| <div></div>
| </amp-list>
| <!-- Invalid: width is mistyped. -->
| <amp-list src="https://data.com/articles.json?ref=CANONICAL_URL"
>> ^~~~~~~~~
amp-list/0.1/test/validator-amp-list.html:112:2 The attribute 'wdith' may not appear in tag 'amp-list'. (see https://www.ampproject.org/docs/reference/components/amp-list) [DISALLOWED_HTML]
amp-list/0.1/test/validator-amp-list.html:123:2 The attribute 'wdith' may not appear in tag 'amp-list'. (see https://www.ampproject.org/docs/reference/components/amp-list) [DISALLOWED_HTML]
| wdith=10 height=10>
| <div></div>
| </amp-list>
| <!-- Invalid: missing at least src or [src]. -->
| <amp-list width=10 height=10>
>> ^~~~~~~~~
amp-list/0.1/test/validator-amp-list.html:117:2 The tag 'amp-list' is missing a mandatory attribute - pick at least one of ['src','[src]']. (see https://www.ampproject.org/docs/reference/components/amp-list) [AMP_TAG_PROBLEM]
amp-list/0.1/test/validator-amp-list.html:128:2 The tag 'amp-list' is missing a mandatory attribute - pick at least one of ['src','[src]']. (see https://www.ampproject.org/docs/reference/components/amp-list) [AMP_TAG_PROBLEM]
| <div></div>
| </amp-list>
| <!-- Invalid: width/height missing, so it's container layout
| which isn't supported. -->
| <amp-list src="https://data.com/articles.json?ref=CANONICAL_URL">
>> ^~~~~~~~~
amp-list/0.1/test/validator-amp-list.html:122:2 Incomplete layout attributes specified for tag 'amp-list'. For example, provide attributes 'width' and 'height'. (see https://www.ampproject.org/docs/reference/components/amp-list) [AMP_LAYOUT_PROBLEM]
amp-list/0.1/test/validator-amp-list.html:133:2 Incomplete layout attributes specified for tag 'amp-list'. For example, provide attributes 'width' and 'height'. (see https://www.ampproject.org/docs/reference/components/amp-list) [AMP_LAYOUT_PROBLEM]
| <div></div>
| </amp-list>
| <!-- Invalid amp-list with load-more attribute -->
| <amp-list width=10 height=10
>> ^~~~~~~~~
amp-list/0.1/test/validator-amp-list.html:126:2 The attribute 'load-more' in tag 'amp-list' is set to the invalid value ''. (see https://www.ampproject.org/docs/reference/components/amp-list) [DISALLOWED_HTML]
amp-list/0.1/test/validator-amp-list.html:137:2 The attribute 'load-more' in tag 'amp-list' is set to the invalid value ''. (see https://www.ampproject.org/docs/reference/components/amp-list) [DISALLOWED_HTML]
| src="https://data.com/articles.json?ref=CANONICAL_URL"
| load-more></amp-list>
| </amp-list>
| <!-- Valid amp-list with bad load-more attribute -->
| <!-- Invalid amp-list with bad load-more attribute -->
| <amp-list width=10 height=10
>> ^~~~~~~~~
amp-list/0.1/test/validator-amp-list.html:131:2 The attribute 'load-more' in tag 'amp-list' is set to the invalid value 'gibberish'. (see https://www.ampproject.org/docs/reference/components/amp-list) [DISALLOWED_HTML]
amp-list/0.1/test/validator-amp-list.html:142:2 The attribute 'load-more' in tag 'amp-list' is set to the invalid value 'gibberish'. (see https://www.ampproject.org/docs/reference/components/amp-list) [DISALLOWED_HTML]
| src="https://data.com/articles.json?ref=CANONICAL_URL"
| load-more="gibberish"
| load-more-bookmark="next"></amp-list>
| </amp-list>
| <!-- Invalid load-more attributes -->
| <div load-more-button></div>
>> ^~~~~~~~~
amp-list/0.1/test/validator-amp-list.html:148:2 The attribute 'load-more-button' may not appear in tag 'div'. [DISALLOWED_HTML]
| <div load-more-loading></div>
>> ^~~~~~~~~
amp-list/0.1/test/validator-amp-list.html:149:2 The attribute 'load-more-loading' may not appear in tag 'div'. [DISALLOWED_HTML]
| <div load-more-failed></div>
>> ^~~~~~~~~
amp-list/0.1/test/validator-amp-list.html:150:2 The attribute 'load-more-failed' may not appear in tag 'div'. [DISALLOWED_HTML]
| <div load-more-end></div>
>> ^~~~~~~~~
amp-list/0.1/test/validator-amp-list.html:151:2 The attribute 'load-more-end' may not appear in tag 'div'. [DISALLOWED_HTML]
| </body>
| </html>
27 changes: 27 additions & 0 deletions extensions/amp-list/validator-amp-list.protoascii
Expand Up @@ -105,6 +105,33 @@ tags: { # <amp-list> with mandatory src and/or [src] attr
supported_layouts: RESPONSIVE
}
}
tags: { # amp-list load-more children
html_format: AMP
spec_name: "AMP-LIST LOAD-MORE CHILDREN"
tag_name: "DIV"
mandatory_parent: "AMP-LIST"
attrs: {
name: "load-more-button"
value: ""
mandatory_oneof: "['load-more-button', 'load-more-failed', 'load-more-end', 'load-more-loading']"
}
attrs: {
name: "load-more-failed"
value: ""
mandatory_oneof: "['load-more-button', 'load-more-failed', 'load-more-end', 'load-more-loading']"
}
attrs: {
name: "load-more-loading"
value: ""
mandatory_oneof: "['load-more-button', 'load-more-failed', 'load-more-end', 'load-more-loading']"

}
attrs: {
name: "load-more-end"
value: ""
mandatory_oneof: "['load-more-button', 'load-more-failed', 'load-more-end', 'load-more-loading']"
}
}
# AMP4EMAIL disallows mustache in src attribute.
tags: { # <amp-list>
html_format: AMP4EMAIL
Expand Down

0 comments on commit c108935

Please sign in to comment.