[flags] land enableTrustedTypesIntegration#35816
Open
rickhanlonii wants to merge 1 commit intofacebook:mainfrom
Open
[flags] land enableTrustedTypesIntegration#35816rickhanlonii wants to merge 1 commit intofacebook:mainfrom
enableTrustedTypesIntegration#35816rickhanlonii wants to merge 1 commit intofacebook:mainfrom
Conversation
eps1lon
approved these changes
Feb 18, 2026
enableTrustedTypesIntegration
1f25a8c to
b9b92b9
Compare
|
Comparing: 4842fbe...b9b92b9 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This flag enables React's integration with the browser Trusted Types API.
The Trusted Types API is a browser security feature that helps prevent DOM-based XSS attacks. When a site enables Trusted Types enforcement via
Content-Security-Policy: require-trusted-types-for 'script', the browser requires that values passed to DOM injection sinks (likeinnerHTML) are typed objects (TrustedHTML,TrustedScript,TrustedScriptURL) created through developer-defined sanitization policies, rather than raw strings.What changed
Previously, React always coerced values to strings (via
'' + value) before passing them to DOM APIs likesetAttributeandinnerHTML. This broke Trusted Types because it converted typed objects into plain strings, which the browser would then reject under Trusted Types enforcement.React now passes values directly to DOM APIs without string coercion, preserving Trusted Types objects so the browser can validate them. This applies to
dangerouslySetInnerHTML, all HTML and SVG attributes, and URL attributes (href,action, etc).Before (broken)
Using Trusted Types with something like
dangerouslySetInnerHTMLwould throw:After (works)
React now passes the TrustedHTML object directly to the DOM without stringifying it:
Non-breaking change