Skip to content

Commit

Permalink
fix(image): forget pass referrerpolicy to real image tag props #2810 (#…
Browse files Browse the repository at this point in the history
…2811)

* fix(image): forget pass referrerpolicy to real image tag props #2810

* fix(image): typo
  • Loading branch information
NWYLZW authored Mar 21, 2024
1 parent 2ce5f99 commit 51d9f0b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/image/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const InternalImage: React.ForwardRefRenderFunction<HTMLDivElement, ImageProps>
className,
src,
style,
alt,
fit,
position,
shape,
Expand All @@ -50,8 +49,14 @@ const InternalImage: React.ForwardRefRenderFunction<HTMLDivElement, ImageProps>
fallback,
onLoad,
onError,
...rest
...waitPassRest
} = props;
const {
// penetrate pass to image tag element props
alt,
referrerpolicy,
...rest
} = waitPassRest;

const { classPrefix } = useConfig();
const imageRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -127,7 +132,7 @@ const InternalImage: React.ForwardRefRenderFunction<HTMLDivElement, ImageProps>
// 这里添加setTimeout是因为CSR image渲染时,onError有时快有时慢,会导致执行顺序不同导致的bug
setTimeout(() => {
if (!isValid && !isFirstError.current) {
// SSR模式下获取不到imaage的合成事件,暂时传递image实例
// SSR模式下获取不到 image 的合成事件,暂时传递 image 实例
handleError(imgRef.current);
}
}, 0);
Expand All @@ -141,7 +146,7 @@ const InternalImage: React.ForwardRefRenderFunction<HTMLDivElement, ImageProps>
if (imgRef.current) {
const { complete, naturalWidth, naturalHeight } = imgRef.current;
if (complete && naturalWidth !== 0 && naturalHeight !== 0) {
// SSR模式下获取不到imaage的合成事件,暂时传递image实例
// SSR模式下获取不到 image 的合成事件,暂时传递 image 实例
handleLoad(imgRef.current);
}
}
Expand Down Expand Up @@ -197,6 +202,7 @@ const InternalImage: React.ForwardRefRenderFunction<HTMLDivElement, ImageProps>
`${classPrefix}-image--position-${position}`,
)}
alt={alt}
referrerPolicy={referrerpolicy}
/>
);
};
Expand Down

0 comments on commit 51d9f0b

Please sign in to comment.