From f8845744d47129a5f0027d47ac838af072d10f2b Mon Sep 17 00:00:00 2001 From: Josh Story Date: Fri, 24 Feb 2023 16:33:58 -0800 Subject: [PATCH] support type in client --- .../react-dom-bindings/src/client/ReactDOMFloatClient.js | 8 +++++++- .../src/server/ReactDOMServerFormatConfig.js | 1 - packages/react-dom/src/__tests__/ReactDOMFloat-test.js | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js b/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js index 7091db0525b9f..275dd5223db2d 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js +++ b/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js @@ -152,7 +152,12 @@ function getDocumentFromRoot(root: HoistableRoot): Document { // ReactDOM.Preload // -------------------------------------- type PreloadAs = ResourceType; -type PreloadOptions = {as: PreloadAs, crossOrigin?: string, integrity?: string}; +type PreloadOptions = { + as: PreloadAs, + crossOrigin?: string, + integrity?: string, + type?: string, +}; function preload(href: string, options: PreloadOptions) { if (__DEV__) { validatePreloadArguments(href, options); @@ -208,6 +213,7 @@ function preloadPropsFromPreloadOptions( as, crossOrigin: as === 'font' ? '' : options.crossOrigin, integrity: options.integrity, + type: options.type, }; } diff --git a/packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js b/packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js index a1b3cf2ed0665..dd86417329a56 100644 --- a/packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js +++ b/packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js @@ -4203,7 +4203,6 @@ type PreloadOptions = { as: PreloadAs, crossOrigin?: string, integrity?: string, - media?: string, type?: string, }; export function preload(href: string, options: PreloadOptions) { diff --git a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js index c8c6da4e74c92..9144d392c56cf 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js @@ -2353,6 +2353,7 @@ body { function ClientApp() { ReactDOM.preload('foo', {as: 'style'}); + ReactDOM.preload('font', {as: 'font', type: 'font/woff2'}); React.useInsertionEffect(() => ReactDOM.preload('bar', {as: 'script'})); React.useLayoutEffect(() => ReactDOM.preload('baz', {as: 'font'})); React.useEffect(() => ReactDOM.preload('qux', {as: 'style'})); @@ -2372,6 +2373,13 @@ body { +