Skip to content

[Fiber] Don't warn when rendering data block scripts#35953

Merged
eps1lon merged 2 commits intomainfrom
sebbie/tt-script-data-block
Mar 3, 2026
Merged

[Fiber] Don't warn when rendering data block scripts#35953
eps1lon merged 2 commits intomainfrom
sebbie/tt-script-data-block

Conversation

@eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Mar 3, 2026

Summary

React will commit <script> tags client-side in a way to blocks them from execution. When that happens we issue a warning when trusted types integration is enabled (introduced in #16157).

However, scripts that contain data blocks (e.g. application/ld+json) are not executed by user agents anyway. In those cases React will no longer warn with this change. Especially because you couldn't follow the warning and put the <script>'s content in a <template> instead and have it work the same way.

How did you test this change?

  • Added test (see first commit for current behavior)

@meta-cla meta-cla bot added the CLA Signed label Mar 3, 2026
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Mar 3, 2026
@react-sizebot
Copy link

Comparing: 4cc5b7a...34da60f

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 611.79 kB 611.79 kB = 108.12 kB 108.12 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 677.72 kB 677.72 kB = 119.08 kB 119.08 kB
facebook-www/ReactDOM-prod.classic.js = 697.72 kB 697.72 kB = 122.59 kB 122.59 kB
facebook-www/ReactDOM-prod.modern.js = 688.03 kB 688.03 kB = 120.97 kB 120.97 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
react-native/implementations/ReactFabric-profiling.fb.js = 466.22 kB 464.90 kB = 78.57 kB 78.23 kB
react-native/implementations/ReactFabric-profiling.js = 465.40 kB 463.94 kB = 78.28 kB 77.96 kB

Generated by 🚫 dangerJS against 34da60f

@eps1lon eps1lon requested a review from rickhanlonii March 3, 2026 17:08
@eps1lon eps1lon marked this pull request as ready for review March 3, 2026 17:08
Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this warning only enabled for enableTrustedTypes anyway?

@eps1lon
Copy link
Collaborator Author

eps1lon commented Mar 3, 2026

Why was this warning only enabled for enableTrustedTypes anyway?

There were plans to enable the warning everywhere after some considerations: #16157 (comment)

Probably just forgotten to revisit.

@eps1lon eps1lon changed the title [trusted types] Don't warn when rendering data block scripts [Fiber] Don't warn when rendering data block scripts Mar 3, 2026
@eps1lon eps1lon merged commit e6f1c33 into main Mar 3, 2026
244 checks passed
@eps1lon eps1lon deleted the sebbie/tt-script-data-block branch March 3, 2026 18:39
github-actions bot pushed a commit that referenced this pull request Mar 3, 2026
github-actions bot pushed a commit that referenced this pull request Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants