Skip to content

Commit

Permalink
Add referrerPolicy option to ReactDOM.preload()
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Jul 11, 2023
1 parent 0a36064 commit 2e38548
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,7 @@ function preloadPropsFromPreloadOptions(
fetchPriority: options.fetchPriority,
imageSrcSet: options.imageSrcSet,
imageSizes: options.imageSizes,
referrerPolicy: options.referrerPolicy,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5564,6 +5564,7 @@ function preloadPropsFromPreloadOptions(
fetchPriority: options.fetchPriority,
imageSrcSet: options.imageSrcSet,
imageSizes: options.imageSizes,
referrerPolicy: options.referrerPolicy,
};
}

Expand Down
28 changes: 28 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMFloat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3585,6 +3585,13 @@ body {
imageSizes: 'makes no sense',
});

ReactDOM.preload('rp', {
as: 'image',
imageSrcSet: 'rpsrcset',
imageSizes: 'rpsizes',
referrerPolicy: 'no-referrer',
});

if (isClient) {
// Will key off href in absense of imageSrcSet
ReactDOM.preload('client', {as: 'image'});
Expand Down Expand Up @@ -3634,6 +3641,13 @@ body {
imagesizes="foosizes"
/>
<link rel="preload" as="somethingelse" href="bar" />
<link
rel="preload"
as="image"
imagesrcset="rpsrcset"
imagesizes="rpsizes"
referrerpolicy="no-referrer"
/>
</head>
<body>hello</body>
</html>,
Expand All @@ -3653,6 +3667,13 @@ body {
imagesizes="foosizes"
/>
<link rel="preload" as="somethingelse" href="bar" />
<link
rel="preload"
as="image"
imagesrcset="rpsrcset"
imagesizes="rpsizes"
referrerpolicy="no-referrer"
/>
</head>
<body>hello</body>
</html>,
Expand All @@ -3672,6 +3693,13 @@ body {
imagesizes="foosizes"
/>
<link rel="preload" as="somethingelse" href="bar" />
<link
rel="preload"
as="image"
imagesrcset="rpsrcset"
imagesizes="rpsizes"
referrerpolicy="no-referrer"
/>
<link rel="preload" as="image" href="client" />
<link rel="preload" as="image" imagesrcset="clientset" />
<link
Expand Down
1 change: 1 addition & 0 deletions packages/react-dom/src/shared/ReactDOMTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type PreloadOptions = {
fetchPriority?: 'high' | 'low' | 'auto',
imageSrcSet?: string,
imageSizes?: string,
referrerPolicy?: string,
};
export type PreinitOptions = {
as: string,
Expand Down

0 comments on commit 2e38548

Please sign in to comment.