Repository navigation
Fix flag rendering inside table cells in Safari - #2866
Merged
Merged
Conversation
Collaborator
Author
|
No actionable findings in PR #2866. The existing Static review only; Safari behavior wasn’t independently tested. |
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.
The scenario
When a user puts
<flux:flag>inside a<flux:table>cell, Safari shows a zoomed-in strip of the flag instead of the whole flag.The problem
The flag's
<img>usessize-full(height: 100%), and WebKit has a legacy rule for percentage heights on images inside table cells: it walks up the containing blocks, and if every one hasheight: autountil it reaches a<td>, it resolves the percentage against the larger of the cell's height and the image's intrinsic height (RenderReplaced.cpp, "Don't let table cells squeeze percent-height replaced elements", webkit#15359).The flag wrapper gets its height from
aspect-ratio, so itsheightis stillautoand the check skips right past it to the cell. The flag SVGs only have aviewBox, so the image gets a height of 342px or 512px. The wrapper clips it withoverflow: hiddenandobject-covercrops the middle of it, which is what shows up as the zoomed-in flag.Outside a table there's no cell in the chain, so the percentage resolves against the wrapper as expected. Chrome and Firefox don't have this rule.
The solution
Position the image absolutely to fill the wrapper, which is already
relative. Percentage heights of absolutely positioned elements resolve against their containing block's padding box, so WebKit's table cell rule doesn't apply.<img src="{{ $src }}" alt="{{ $alt }}" loading="lazy" decoding="async" - class="size-full object-cover" + class="absolute inset-0 size-full object-cover" >The wrapper's size comes only from its width and
aspect-ratio, so taking the image out of flow doesn't change it. All sizes,circle, the fallback globe and customw-*/h-*classes render the same as before outside tables.Fixes #2864