@@ -265,10 +262,7 @@ function handleLoading(
setBlurComplete(true)
}
if (onLoadingCompleteRef?.current) {
- const { naturalWidth, naturalHeight } = img
- // Pass back read-only primitive values but not the
- // underlying DOM element because it could be misused.
- onLoadingCompleteRef.current({ naturalWidth, naturalHeight })
+ onLoadingCompleteRef.current(img)
}
if (process.env.NODE_ENV !== 'production') {
if (img.getAttribute('data-nimg') === 'future-fill') {
diff --git a/test/integration/image-future/default/pages/on-loading-complete.js b/test/integration/image-future/default/pages/on-loading-complete.js
index b89d655268e37..da60e069f3195 100644
--- a/test/integration/image-future/default/pages/on-loading-complete.js
+++ b/test/integration/image-future/default/pages/on-loading-complete.js
@@ -105,13 +105,15 @@ function ImageWithMessage({ id, idToCount, setIdToCount, ...props }) {
{
+ onLoadingComplete={(img) => {
+ const { naturalWidth, naturalHeight, nodeName } = img
let count = idToCount[id] || 0
count++
idToCount[id] = count
setIdToCount(idToCount)
+ const name = nodeName.toLocaleLowerCase()
setMsg(
- `loaded ${count} img${id} with dimensions ${naturalWidth}x${naturalHeight}`
+ `loaded ${count} ${name}${id} with dimensions ${naturalWidth}x${naturalHeight}`
)
}}
{...props}