-
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
✨ Validator support for transformed intrinsic layout #24119
Conversation
validator/validator-main.protoascii
Outdated
mandatory_parent: "I-AMPHTML-SIZER" | ||
attrs: { | ||
name: "class" | ||
value_regex: "i-amphtml-intrinsic-sizer" |
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.
can this just be value:
?
Note that in validation rules, value_regex always means full match and blacklisted_value_regex is partial match. This is a bit confusing, but it is in place to avoid mistakes in the wrong direction (looser validation rules than expected).
If you intended partial match, use ".*i-amphtml-intrinsic-sizer.*"
and also ignore my dispatch key comment.
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.
First I had it as value, but that caused the test to fail. I couldn't work out why. I assumed that was specific to how class
is handled:
| <i-amphtml-sizer class="i-amphtml-sizer"><img alt="" aria-hidden="true" class="i-amphtml-intrinsic-sizer" role="presentation" src="data:image/svg+xml;charset=utf-8,<svg height="100" width="300" xmlns="http://www.w3.org/2000/svg" version="1.1"/>"></i-amphtml-sizer>
>> ^~~~~~~~~
transformed_feature_tests/server_side_rendering.html:40:45 The mandatory attribute 'class' is missing in tag 'IMG-I-AMPHTML-INTRINSIC-SIZER'. [DISALLOWED_HTML]
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.
Thats odd. Is the example you give the result for that test? Did you verify the spelling?
e030b1c
to
bdb46ff
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.
Finally had some time to look into this again. I've addressed the comments. The current version:
- passes the tests
- accepts the intrinsic layout sizer
However, theoretically there are still a few validation rules possible:
- ensure that sizer matches layout, e.g. currently it'd be valid for the responsive sizer to have an
img
child. - ensure that the class attribute is set for the intrinsic sizer:
<i-amphtml-sizer class="i-amphtml-sizer">
I'd need some guidance though on how to best implement these in the validator (in particular how to figure out from a child ndoe whether one of the parent nodes has a specific attribute value set).
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.
I've split i-amphtml-sizer
into two tag specs. Now, sizer attributes area correctly verified. I couldn't figure out though how to set I-AMPHTML-SIZER-INTRINSIC
as the mandatory parent.
PTAL
Hey @ampproject/wg-caching, these files were changed:
|
The amp-owners-bot popped this back to my visibility. What's the latest status on this? Do you need additional review? |
Intrinsic layout SSR adds the following sizer element: ```html <amp-img height="100" width="300" layout="intrinsic" class="i-amphtml-layout-intrinsic i-amphtml-layout-size-defined" i-amphtml-layout="intrinsic"> <i-amphtml-sizer class="i-amphtml-sizer"> <img alt="" aria-hidden="true" class="i-amphtml-intrinsic-sizer" role="presentation" src="data:image/svg+xml;charset=utf-8,<svg height="100" width="300" xmlns="http://www.w3.org/2000/svg" version="1.1"/>"> </i-amphtml-sizer> </amp-img> ``` This commit extends the `i-amphtml-sizer` validation rules to alternatively support the intrinsic sizer element. The SVG sizer image is validated via a regex checking if the `src` value is an SVG.
0dbf3b6
to
4d77fb8
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.
I've updated the PR to add the missing check for the intrinsic parent (now that b/139869098 has landed). PTAL
Looks good to me. @honeybadgerdontcare did you have any other requirements? When ready, please approve. |
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.
lgtm after nit addressed
* cl/286094937 Allow validator to support LTS release channel for runtime and extensions * cl/286215939 Revision bump for #24119 * exempt validator engine
Validator support for transformed intrinsic layout Intrinsic layout SSR adds the following sizer element: ```html <amp-img height="100" width="300" layout="intrinsic" class="i-amphtml-layout-intrinsic i-amphtml-layout-size-defined" i-amphtml-layout="intrinsic"> <i-amphtml-sizer class="i-amphtml-sizer"> <img alt="" aria-hidden="true" class="i-amphtml-intrinsic-sizer" role="presentation" src="data:image/svg+xml;charset=utf-8,<svg height="100" width="300" xmlns="http://www.w3.org/2000/svg" version="1.1"/>"> </i-amphtml-sizer> </amp-img> ``` This commit extends the `i-amphtml-sizer` validation rules to alternatively support the intrinsic sizer element. The SVG sizer image is validated via a regex checking if the `src` value is an SVG.
* cl/286094937 Allow validator to support LTS release channel for runtime and extensions * cl/286215939 Revision bump for ampproject#24119 * exempt validator engine
Intrinsic layout SSR adds the following sizer element:
This commit extends the
i-amphtml-sizer
validation rules toalternatively support the intrinsic sizer element. The SVG sizer image
is validated via a regex checking if the
src
value is an SVG.