From 4f4e1f0e658a695688fea094f7da64fd542b9b58 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Thu, 16 Jun 2022 19:44:50 +0200 Subject: [PATCH 1/4] React DOM: Add support for `hidden="until-found"` --- .../attribute-behavior/AttributeTableSnapshot.md | 14 +++++++------- .../src/client/ReactDOMComponent.js | 4 ++-- .../src/server/ReactFizzConfigDOM.js | 7 +++++-- .../src/shared/ReactDOMUnknownPropertyHook.js | 3 +-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/fixtures/attribute-behavior/AttributeTableSnapshot.md b/fixtures/attribute-behavior/AttributeTableSnapshot.md index f3a8ebfde9923..220cbd0d3ed51 100644 --- a/fixtures/attribute-behavior/AttributeTableSnapshot.md +++ b/fixtures/attribute-behavior/AttributeTableSnapshot.md @@ -4926,21 +4926,21 @@ ## `hidden` (on `
` inside `
`) | Test Case | Flags | Result | | --- | --- | --- | -| `hidden=(string)`| (changed)| `` | -| `hidden=(empty string)`| (initial)| `` | -| `hidden=(array with string)`| (changed)| `` | +| `hidden=(string)`| (changed)| `"until-found"` | +| `hidden=(empty string)`| (changed)| `` | +| `hidden=(array with string)`| (changed)| `"until-found"` | | `hidden=(empty array)`| (changed)| `` | | `hidden=(object)`| (changed)| `` | | `hidden=(numeric string)`| (changed)| `` | | `hidden=(-1)`| (changed)| `` | -| `hidden=(0)`| (initial)| `` | +| `hidden=(0)`| (changed)| `` | | `hidden=(integer)`| (changed)| `` | -| `hidden=(NaN)`| (initial, warning)| `` | +| `hidden=(NaN)`| (changed, warning)| `` | | `hidden=(float)`| (changed)| `` | | `hidden=(true)`| (changed)| `` | | `hidden=(false)`| (initial)| `` | -| `hidden=(string 'true')`| (changed, warning)| `` | -| `hidden=(string 'false')`| (changed, warning)| `` | +| `hidden=(string 'true')`| (changed)| `` | +| `hidden=(string 'false')`| (changed)| `` | | `hidden=(string 'on')`| (changed)| `` | | `hidden=(string 'off')`| (changed)| `` | | `hidden=(symbol)`| (initial, warning)| `` | diff --git a/packages/react-dom-bindings/src/client/ReactDOMComponent.js b/packages/react-dom-bindings/src/client/ReactDOMComponent.js index 24462c1d2bb5a..484d6b674894d 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMComponent.js +++ b/packages/react-dom-bindings/src/client/ReactDOMComponent.js @@ -722,7 +722,6 @@ function setProp( case 'disablePictureInPicture': case 'disableRemotePlayback': case 'formNoValidate': - case 'hidden': case 'loop': case 'noModule': case 'noValidate': @@ -743,6 +742,7 @@ function setProp( } // Overloaded Boolean case 'capture': + case 'hidden': case 'download': { // An attribute that can be used as a flag as well as with a value. // When true, it should be present (set either to an empty string or its name). @@ -2507,7 +2507,6 @@ function diffHydratedGenericElement( case 'disablePictureInPicture': case 'disableRemotePlayback': case 'formNoValidate': - case 'hidden': case 'loop': case 'noModule': case 'noValidate': @@ -2530,6 +2529,7 @@ function diffHydratedGenericElement( continue; } case 'capture': + case 'hidden': case 'download': { hydrateOverloadedBooleanAttribute( domElement, diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js index a469b5587d79a..e5a1d691e6169 100644 --- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js +++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js @@ -1290,7 +1290,6 @@ function pushAttribute( case 'disablePictureInPicture': case 'disableRemotePlayback': case 'formNoValidate': - case 'hidden': case 'loop': case 'noModule': case 'noValidate': @@ -1313,6 +1312,7 @@ function pushAttribute( return; } case 'capture': + case 'hidden': case 'download': { // Overloaded Boolean if (value === true) { @@ -5189,7 +5189,10 @@ function writeStyleResourceAttributeInAttr( if (value === false) { return; } - attributeValue = ''; + if (__DEV__) { + checkAttributeStringCoercion(value, attributeName); + } + attributeValue = '' + (value: any); break; } diff --git a/packages/react-dom-bindings/src/shared/ReactDOMUnknownPropertyHook.js b/packages/react-dom-bindings/src/shared/ReactDOMUnknownPropertyHook.js index 3dbb1d8e2c315..c08f1f7ac41b0 100644 --- a/packages/react-dom-bindings/src/shared/ReactDOMUnknownPropertyHook.js +++ b/packages/react-dom-bindings/src/shared/ReactDOMUnknownPropertyHook.js @@ -223,7 +223,6 @@ function validateProperty(tagName, name, value, eventRegistry) { case 'disablePictureInPicture': case 'disableRemotePlayback': case 'formNoValidate': - case 'hidden': case 'loop': case 'noModule': case 'noValidate': @@ -236,6 +235,7 @@ function validateProperty(tagName, name, value, eventRegistry) { case 'seamless': case 'itemScope': case 'capture': + case 'hidden': case 'download': { // Boolean properties can accept boolean values return true; @@ -300,7 +300,6 @@ function validateProperty(tagName, name, value, eventRegistry) { case 'disablePictureInPicture': case 'disableRemotePlayback': case 'formNoValidate': - case 'hidden': case 'loop': case 'noModule': case 'noValidate': From 8d312589e3d4fcfc4f4cc5191c56891a6ae528df Mon Sep 17 00:00:00 2001 From: eps1lon Date: Thu, 16 Jun 2022 19:59:11 +0200 Subject: [PATCH 2/4] Update tests --- .../src/__tests__/ReactDOMComponent-test.js | 16 +++--- ...eactDOMServerIntegrationAttributes-test.js | 51 +++++++++---------- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOMComponent-test.js b/packages/react-dom/src/__tests__/ReactDOMComponent-test.js index 6541293f51333..a41a1213a0a29 100644 --- a/packages/react-dom/src/__tests__/ReactDOMComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMComponent-test.js @@ -3452,15 +3452,15 @@ describe('ReactDOMComponent', () => { const root = ReactDOMClient.createRoot(container); await act(() => { - root.render(