mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[Fiber][Float] preinitialized stylesheets should support integrity option (#26881)
preinitialized stylesheets did not render the integrity option on the client implementation of Float. This was an oversight.
This commit is contained in:
@@ -2394,6 +2394,7 @@ function stylesheetPropsFromPreinitOptions(
|
||||
href,
|
||||
'data-precedence': precedence,
|
||||
crossOrigin: options.crossOrigin,
|
||||
integrity: options.integrity,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4409,6 +4409,71 @@ body {
|
||||
</html>,
|
||||
);
|
||||
});
|
||||
|
||||
it('accepts an `integrity` option for `as: "style"`', async () => {
|
||||
function Component({src, hash}) {
|
||||
ReactDOM.preinit(src, {as: 'style', integrity: hash});
|
||||
return 'hello';
|
||||
}
|
||||
|
||||
await act(() => {
|
||||
renderToPipeableStream(
|
||||
<html>
|
||||
<body>
|
||||
<Component src="foo" hash="foo hash" />
|
||||
</body>
|
||||
</html>,
|
||||
{
|
||||
nonce: 'R4nD0m',
|
||||
},
|
||||
).pipe(writable);
|
||||
});
|
||||
|
||||
expect(getMeaningfulChildren(document)).toEqual(
|
||||
<html>
|
||||
<head>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="foo"
|
||||
integrity="foo hash"
|
||||
data-precedence="default"
|
||||
/>
|
||||
</head>
|
||||
<body>hello</body>
|
||||
</html>,
|
||||
);
|
||||
|
||||
await clientAct(() => {
|
||||
ReactDOMClient.hydrateRoot(
|
||||
document,
|
||||
<html>
|
||||
<body>
|
||||
<Component src="bar" hash="bar hash" />
|
||||
</body>
|
||||
</html>,
|
||||
);
|
||||
});
|
||||
|
||||
expect(getMeaningfulChildren(document)).toEqual(
|
||||
<html>
|
||||
<head>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="foo"
|
||||
integrity="foo hash"
|
||||
data-precedence="default"
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="bar"
|
||||
integrity="bar hash"
|
||||
data-precedence="default"
|
||||
/>
|
||||
</head>
|
||||
<body>hello</body>
|
||||
</html>,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Stylesheet Resources', () => {
|
||||
|
||||
Reference in New Issue
Block a user