Skip to content
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

Add position styling to future fill images #39438

Merged
merged 5 commits into from Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/next/client/future/image.tsx
Expand Up @@ -576,6 +576,10 @@ export default function Image({
position: 'absolute',
height: '100%',
width: '100%',
left: 0,
top: 0,
right: 0,
bottom: 0,
}
: {},
showAltText || placeholder === 'blur' ? {} : { color: 'transparent' },
Expand Down
7 changes: 7 additions & 0 deletions test/integration/image-future/default/pages/fill.js
Expand Up @@ -16,6 +16,13 @@ const Page = () => {
>
<Image id="fill-image-1" src="/wide.png" sizes="300px" fill />
</div>
<span>Non-fill image:</span>
<Image
id="non-fill-image"
src="/test.jpg"
width="400"
height="400"
></Image>
atcastle marked this conversation as resolved.
Show resolved Hide resolved
</div>
)
}
Expand Down
18 changes: 18 additions & 0 deletions test/integration/image-future/default/test/index.test.js
Expand Up @@ -992,6 +992,24 @@ function runTests(mode) {
)
).toBe('100%')
})
it('should add position styles to fill images', async () => {
expect(
await browser.eval(`document.getElementById("fill-image-1").style.left`)
).toBe('0px')
expect(
await browser.eval(`document.getElementById("fill-image-1").style.top`)
).toBe('0px')
expect(
await browser.eval(
`document.getElementById("fill-image-1").style.right`
)
).toBe('0px')
expect(
await browser.eval(
`document.getElementById("fill-image-1").style.bottom`
)
).toBe('0px')
atcastle marked this conversation as resolved.
Show resolved Hide resolved
})
if (mode === 'dev') {
it('should not log incorrect warnings', async () => {
await waitFor(1000)
Expand Down