GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Float] Don't preload images inside `<noscript>` (#28815) · react/react@dc6a7e0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • react-dom-bindings/src/server
      • ReactFizzConfigDOM.js
    • react-dom/src/__tests__
      • ReactDOMFloat-test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js‎

Copy file name to clipboardExpand all lines: packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,7 +2762,7 @@ function pushImg(
27622762
props: Object,
27632763
resumableState: ResumableState,
27642764
renderState: RenderState,
2765-
pictureTagInScope: boolean,
2765+
pictureOrNoScriptTagInScope: boolean,
27662766
): null {
27672767
const {src, srcSet} = props;
27682768
if (
@@ -2771,7 +2771,7 @@ function pushImg(
27712771
(typeof src === 'string' || src == null) &&
27722772
(typeof srcSet === 'string' || srcSet == null) &&
27732773
props.fetchPriority !== 'low' &&
2774-
pictureTagInScope === false &&
2774+
pictureOrNoScriptTagInScope === false &&
27752775
// We exclude data URIs in src and srcSet since these should not be preloaded
27762776
!(
27772777
typeof src === 'string' &&
@@ -3599,7 +3599,7 @@ export function pushStartInstance(
35993599
props,
36003600
resumableState,
36013601
renderState,
3602-
!!(formatContext.tagScope & PICTURE_SCOPE),
3602+
!!(formatContext.tagScope & (PICTURE_SCOPE | NOSCRIPT_SCOPE)),
36033603
);
36043604
}
36053605
// Omitted close tags
Collapse file

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

Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMFloat-test.js
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4261,6 +4261,38 @@ body {
42614261
);
42624262
});
42634263

4264+
// Fixes: https://github.com/facebook/react/issues/27910
4265+
it('omits preloads for images inside noscript tags', async () => {
4266+
function App() {
4267+
return (
4268+
<html>
4269+
<body>
4270+
<img src="foo" />
4271+
<noscript>
4272+
<img src="bar" />
4273+
</noscript>
4274+
</body>
4275+
</html>
4276+
);
4277+
}
4278+
4279+
await act(() => {
4280+
renderToPipeableStream(<App />).pipe(writable);
4281+
});
4282+
4283+
expect(getMeaningfulChildren(document)).toEqual(
4284+
<html>
4285+
<head>
4286+
<link rel="preload" href="foo" as="image" />
4287+
</head>
4288+
<body>
4289+
<img src="foo" />
4290+
<noscript>&lt;img src="bar"&gt;</noscript>
4291+
</body>
4292+
</html>,
4293+
);
4294+
});
4295+
42644296
it('should handle media on image preload', async () => {
42654297
function App({isClient}) {
42664298
ReactDOM.preload('/server', {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.