Skip to content

Commit f884574

Browse files
committed
support type in client
1 parent 05c88a2 commit f884574

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

packages/react-dom-bindings/src/client/ReactDOMFloatClient.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ function getDocumentFromRoot(root: HoistableRoot): Document {
152152
// ReactDOM.Preload
153153
// --------------------------------------
154154
type PreloadAs = ResourceType;
155-
type PreloadOptions = {as: PreloadAs, crossOrigin?: string, integrity?: string};
155+
type PreloadOptions = {
156+
as: PreloadAs,
157+
crossOrigin?: string,
158+
integrity?: string,
159+
type?: string,
160+
};
156161
function preload(href: string, options: PreloadOptions) {
157162
if (__DEV__) {
158163
validatePreloadArguments(href, options);
@@ -208,6 +213,7 @@ function preloadPropsFromPreloadOptions(
208213
as,
209214
crossOrigin: as === 'font' ? '' : options.crossOrigin,
210215
integrity: options.integrity,
216+
type: options.type,
211217
};
212218
}
213219

packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4203,7 +4203,6 @@ type PreloadOptions = {
42034203
as: PreloadAs,
42044204
crossOrigin?: string,
42054205
integrity?: string,
4206-
media?: string,
42074206
type?: string,
42084207
};
42094208
export function preload(href: string, options: PreloadOptions) {

packages/react-dom/src/__tests__/ReactDOMFloat-test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,7 @@ body {
23532353

23542354
function ClientApp() {
23552355
ReactDOM.preload('foo', {as: 'style'});
2356+
ReactDOM.preload('font', {as: 'font', type: 'font/woff2'});
23562357
React.useInsertionEffect(() => ReactDOM.preload('bar', {as: 'script'}));
23572358
React.useLayoutEffect(() => ReactDOM.preload('baz', {as: 'font'}));
23582359
React.useEffect(() => ReactDOM.preload('qux', {as: 'style'}));
@@ -2372,6 +2373,13 @@ body {
23722373
<html>
23732374
<head>
23742375
<link rel="preload" as="style" href="foo" />
2376+
<link
2377+
rel="preload"
2378+
as="font"
2379+
href="font"
2380+
crossorigin=""
2381+
type="font/woff2"
2382+
/>
23752383
<link rel="preload" as="font" href="baz" crossorigin="" />
23762384
<link rel="preload" as="style" href="qux" />
23772385
</head>

0 commit comments

Comments
 (0)