Unverified Commit 8e203457 authored by Steven's avatar Steven Committed by GitHub

Revert "chore(next/image): remove deprecation of `onLoadingComplete` temporarily" (#57024)

Reverts vercel/next.js#57020

This should be safe to land again after the patch release
parent 4c2b34ea
...@@ -38,6 +38,10 @@ export type ImageProps = Omit< ...@@ -38,6 +38,10 @@ export type ImageProps = Omit<
placeholder?: PlaceholderValue placeholder?: PlaceholderValue
blurDataURL?: string blurDataURL?: string
unoptimized?: boolean unoptimized?: boolean
/**
* @deprecated Use `onLoad` instead.
* @see https://nextjs.org/docs/app/api-reference/components/image#onload
*/
onLoadingComplete?: OnLoadingComplete onLoadingComplete?: OnLoadingComplete
/** /**
* @deprecated Use `fill` prop instead of `layout="fill"` or change import to `next/legacy/image`. * @deprecated Use `fill` prop instead of `layout="fill"` or change import to `next/legacy/image`.
...@@ -523,6 +527,12 @@ export function getImgProps( ...@@ -523,6 +527,12 @@ export function getImgProps(
} }
} }
if (onLoadingComplete) {
warnOnce(
`Image with src "${src}" is using deprecated "onLoadingComplete" property. Please use the "onLoad" property instead.`
)
}
for (const [legacyKey, legacyValue] of Object.entries({ for (const [legacyKey, legacyValue] of Object.entries({
layout, layout,
objectFit, objectFit,
......
...@@ -357,6 +357,15 @@ function runTests(mode) { ...@@ -357,6 +357,15 @@ function runTests(mode) {
() => browser.eval(`document.getElementById("msg9").textContent`), () => browser.eval(`document.getElementById("msg9").textContent`),
'loaded 1 img9 with dimensions 400x400' 'loaded 1 img9 with dimensions 400x400'
) )
if (mode === 'dev') {
const warnings = (await browser.log('browser'))
.map((log) => log.message)
.join('\n')
expect(warnings).toMatch(
/Image with src "(.*)" is using deprecated "onLoadingComplete" property/gm
)
}
}) })
it('should callback native onLoad with sythetic event', async () => { it('should callback native onLoad with sythetic event', async () => {
......
...@@ -358,6 +358,15 @@ function runTests(mode) { ...@@ -358,6 +358,15 @@ function runTests(mode) {
() => browser.eval(`document.getElementById("msg9").textContent`), () => browser.eval(`document.getElementById("msg9").textContent`),
'loaded 1 img9 with dimensions 400x400' 'loaded 1 img9 with dimensions 400x400'
) )
if (mode === 'dev') {
const warnings = (await browser.log('browser'))
.map((log) => log.message)
.join('\n')
expect(warnings).toMatch(
/Image with src "(.*)" is using deprecated "onLoadingComplete" property/gm
)
}
}) })
it('should callback native onLoad with sythetic event', async () => { it('should callback native onLoad with sythetic event', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment