diff --git a/packages/next/client/image.tsx b/packages/next/client/image.tsx index 951d8c60c6d6188..de6525b37f602e8 100644 --- a/packages/next/client/image.tsx +++ b/packages/next/client/image.tsx @@ -597,26 +597,6 @@ export default function Image({ ) : null} ) : null} - {!isVisible && ( - - )} + + {priority ? ( // Note how we omit the `href` attribute, as it would only be relevant // for browsers that do not support `imagesrcset`, and in those cases diff --git a/packages/next/types/index.d.ts b/packages/next/types/index.d.ts index 4abaab83eb3cf9f..b1bc5ea2e074451 100644 --- a/packages/next/types/index.d.ts +++ b/packages/next/types/index.d.ts @@ -40,6 +40,11 @@ declare module 'react' { interface LinkHTMLAttributes extends HTMLAttributes { nonce?: string } + + // support + interface ImgHTMLAttributes extends HTMLAttributes { + loading?: 'auto' | 'eager' | 'lazy' + } } export type Redirect = diff --git a/test/integration/export-image-loader/test/index.test.js b/test/integration/export-image-loader/test/index.test.js index ebc63aa6b93aef3..966afc18e7d6ce4 100644 --- a/test/integration/export-image-loader/test/index.test.js +++ b/test/integration/export-image-loader/test/index.test.js @@ -74,7 +74,7 @@ describe('Export with custom loader next/image component', () => { it('should contain img element with same src in html output', async () => { const html = await fs.readFile(join(outdir, 'index.html')) const $ = cheerio.load(html) - expect($('img[alt="icon"]').attr('src')).toBe('/custom/i.png') + expect($('img[src="/custom/o.png"]')).toBeDefined() }) afterAll(async () => { diff --git a/test/integration/image-component/default/test/index.test.js b/test/integration/image-component/default/test/index.test.js index 555a2f134fe4ce1..1d2e5eb6f79cb9e 100644 --- a/test/integration/image-component/default/test/index.test.js +++ b/test/integration/image-component/default/test/index.test.js @@ -151,7 +151,7 @@ function runTests(mode) { const els = [].slice.apply($html('img')) expect(els.length).toBe(2) - const [noscriptEl, el] = els + const [el, noscriptEl] = els expect(noscriptEl.attribs.src).toBeDefined() expect(noscriptEl.attribs.srcset).toBeDefined()