[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:
Josh Story
2023-05-31 13:48:19 -07:00
committed by GitHub
parent 1cea384480
commit e1e68b9f7f
2 changed files with 66 additions and 0 deletions
@@ -2394,6 +2394,7 @@ function stylesheetPropsFromPreinitOptions(
href,
'data-precedence': precedence,
crossOrigin: options.crossOrigin,
integrity: options.integrity,
};
}
+65
View File
@@ -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', () => {