React 19: patch to support legacy inert attribute values#79475
Conversation
|
Size Change: +25 B (0%) Total Size: 7.51 MB 📦 View Changed
|
|
By the way, this patch again corresponds to a feature flag that used to be there during the React 18 -> 19 transition. It was called |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in ff4c586. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/28085515159
|
This is another patch we're applying to React 19 to improve compat with React 18. When faced with a
<div inert="">element, both versions treat it differently. React 18 sets the empty string value as-is as the DOM attribute value. And in DOM, any value, even'', means "true". React 19, however, converts the empty string to boolean, and because empty string is falsy, the result is "false".We're applying a patch that interprets the
''value universally astrue. Inreact-domthere is code:which issues a warning in dev mode for this tricky case, but otherwise does nothing. Our patch adds this statement at the end of the
casestatement:And that coerces the string value to
true.I adapted the e2e tests that checks for these incompatibilities: the previous check for
inertwasn't catching the problematic case.The PR also does a refactoring of the patching code, as it has grown somewhat since it was initially written.