[DOM] Treat hidden as overloaded boolean to support hidden="until-found"#35784
[DOM] Treat hidden as overloaded boolean to support hidden="until-found"#35784veeceey wants to merge 1 commit intofacebook:mainfrom
Conversation
…found"
The hidden attribute was treated as a plain boolean, which meant any
truthy value was coerced to an empty string. This prevented using the
hidden="until-found" value that is now supported in all major browsers
(Chrome 102+, Firefox 139+, Safari 26.2+).
Move hidden from the boolean attribute list to the overloaded boolean
list (alongside capture and download), so that:
- hidden={true} renders as hidden=""
- hidden={false} removes the attribute
- hidden="until-found" renders as hidden="until-found"
Fixes facebook#24740
|
Hi @veeceey! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Summary
The
hiddenHTML attribute was being treated as a plain boolean in React's DOM handling. This meant that any truthy value (including strings like"until-found") was always coerced to an empty string attribute (hidden=""). This prevented using thehidden="until-found"feature that enables content to be searchable by the browser's find-in-page while remaining visually hidden.This PR reclassifies
hiddenfrom a boolean attribute to an overloaded boolean (same category ascaptureanddownload), so that:hidden={true}rendershidden=""(unchanged)hidden={false}removes the attribute (unchanged)hidden="until-found"now correctly rendershidden="until-found"The
hidden="until-found"value is now supported across all major browsers:Changes:
ReactDOMComponent.js): movedhiddenfrom the boolean to the overloaded boolean switch case in bothsetPropanddiffHydratedGenericElementReactFizzConfigDOM.js): movedhiddenfrom boolean to overloaded boolean inpushAttribute, updatedwriteStyleResourceAttributeInJSandwriteStyleResourceAttributeInAttrto preserve string valuesReactDOMUnknownPropertyHook.js): removedhiddenfrom the boolean warning list so string values don't trigger false warningsReactFiberConfigDOM.js): updatedhiddentype frombooleantoboolean | stringHow did you test this change?
Ran the full test suites for all affected test files:
ReactDOMComponent-test.js- 167 passedReactDOMServerIntegrationAttributes-test.js- 555 passedReactDOMFizzServer-test.js- 156 passedAdded new tests verifying
hidden={true},hidden={false}, andhidden="until-found"behavior for both client and server rendering.Fixes #24740