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

Change data-nimg attribute on next/image #41612

Merged
merged 4 commits into from Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 2 deletions packages/next/client/image.tsx
Expand Up @@ -299,7 +299,7 @@ function handleLoading(
onLoadingCompleteRef.current(img)
}
if (process.env.NODE_ENV !== 'production') {
if (img.getAttribute('data-nimg') === 'future-fill') {
if (img.getAttribute('data-nimg') === 'fill') {
if (
!img.getAttribute('sizes') ||
img.getAttribute('sizes') === '100vw'
Expand Down Expand Up @@ -378,7 +378,7 @@ const ImageElement = ({
width={widthInt}
height={heightInt}
decoding="async"
data-nimg={`future${fill ? '-fill' : ''}`}
data-nimg={fill ? 'fill' : '1'}
className={className}
// @ts-ignore - TODO: upgrade to `@types/react@17`
loading={loading}
Expand Down
8 changes: 4 additions & 4 deletions test/integration/next-image-new/default/test/index.test.ts
Expand Up @@ -272,7 +272,7 @@ function runTests(mode) {
browser.eval(
`document.getElementById("img8").getAttribute("data-nimg")`
),
'future'
'1'
)
await check(
() => browser.eval(`document.getElementById("img8").currentSrc`),
Expand All @@ -288,7 +288,7 @@ function runTests(mode) {
browser.eval(
`document.getElementById("img8").getAttribute("data-nimg")`
),
'future'
'1'
)
await check(
() => browser.eval(`document.getElementById("img8").currentSrc`),
Expand Down Expand Up @@ -336,7 +336,7 @@ function runTests(mode) {
browser.eval(
`document.getElementById("img5").getAttribute("data-nimg")`
),
'future'
'1'
)

await browser.eval('document.getElementById("toggle").click()')
Expand Down Expand Up @@ -1047,7 +1047,7 @@ function runTests(mode) {
it('should include a data-attribute on fill images', async () => {
expect(
await browser.elementById('fill-image-1').getAttribute('data-nimg')
).toBe('future-fill')
).toBe('fill')
})
it('should add position:absolute to fill images', async () => {
expect(await getComputedStyle(browser, 'fill-image-1', 'position')).toBe(
Expand Down