Cast i-amphtml-intrinsic-sizer dimensions to integers to prevent AMP validation errors#4506
Merged
westonruter merged 1 commit intodevelopfrom Apr 2, 2020
Merged
Conversation
9defbda to
b0c46ac
Compare
Collaborator
|
Why didn't you go with the CSS approach you've proposed here: ampproject/amphtml#27528 (comment) ? |
Member
Author
@schlessera Because that would break validation. It has to match this pattern: |
Collaborator
|
Ah, yes, obviously! |
schlessera
approved these changes
Apr 2, 2020
Member
Author
|
Pre-release build for testing: amp.zip (v1.5.2-alpha-20200402T163153Z-b54691494) |
Member
westonruter
added a commit
that referenced
this pull request
Apr 3, 2020
* tag '1.5.2': Bump 1.5.2 Bump version to 1.5.1-RC1 Cache response status and headers when fetching external stylesheets (#4509) Fix securing multi-line mustache templates (#4521) Add CSS monitoring time series to Site Health debugging info (#4519) Update hostname used for WordPress TV embeds to fix external HTTP requests (#4524) Fix processing of element child sanitization loop when invalid elements are replaced with children (#4512) Account for more YouTube URL formats (#4508) Update selected featured image ID on select (#4453) Raise default threshold for disabling CSS caching (#4513) Cast i-amphtml-intrinsic-sizer dimensions to integers (#4506) Only move meta tags to the head when required and add processing for meta[http-equiv] (#4505) Fix failing tests (#4507) Bump 1.5.2-alpha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Until ampproject/amphtml#27528 is resolved, decimal dimensions are not valid in the
i-amphtml-intrinsic-sizerelement. The quick fix to prevent requiring users to disable the Optimizer is to cast the dimensions to integers.Note that casting to integers (aka flooring or rounding down) is being done to prevent a situation where two elements
99.5px-wide are displayed inline inside of a container that is199pxwide. If rounding were performed, then the two elements would no longer fit on the same line. This is worse than the alternative when rounding down, which is the presence of a 1px gap.Note that browsers support sub-pixel rendering, so decimal dimensions are not rounded (at least in Chrome, Safari, and Firefox): https://codepen.io/westonruter/pen/abOxNaq
Fixes #4493
Checklist