From 28fc980ef2c563e3086ae5b0b2e6293de48ae0d4 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Tue, 2 Apr 2024 17:09:43 +0200 Subject: [PATCH] Cleanup enableNewBooleanProps (#28712) --- .../src/client/ReactDOMComponent.js | 3 +- .../src/server/ReactFizzConfigDOM.js | 39 +++++++------------ 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/packages/react-dom-bindings/src/client/ReactDOMComponent.js b/packages/react-dom-bindings/src/client/ReactDOMComponent.js index 715b241cdb..ee26765e5b 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMComponent.js +++ b/packages/react-dom-bindings/src/client/ReactDOMComponent.js @@ -681,7 +681,7 @@ function setProp( } } } - // fallthrough for new boolean props without the flag on + // Fallthrough for boolean props that don't have a warning for empty strings. case 'allowFullScreen': case 'async': case 'autoPlay': @@ -2783,7 +2783,6 @@ function diffHydratedGenericElement( serverDifferences, ); continue; - // fallthrough for new boolean props without the flag on default: { if ( // shouldIgnoreAttribute diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js index e5b7d150fa..623bedd92e 100644 --- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js +++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js @@ -1301,6 +1301,21 @@ function pushAttribute( } return; } + case 'inert': { + if (__DEV__) { + if (value === '' && !didWarnForNewBooleanPropsWithEmptyValue[name]) { + didWarnForNewBooleanPropsWithEmptyValue[name] = true; + console.error( + 'Received an empty string for a boolean attribute `%s`. ' + + 'This will treat the attribute as if it were false. ' + + 'Either pass `false` to silence this warning, or ' + + 'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.', + name, + ); + } + } + } + // Fallthrough for boolean props that don't have a warning for empty strings. case 'allowFullScreen': case 'async': case 'autoPlay': @@ -1421,30 +1436,6 @@ function pushAttribute( case 'xmlSpace': pushStringAttribute(target, 'xml:space', value); return; - case 'inert': { - if (__DEV__) { - if (value === '' && !didWarnForNewBooleanPropsWithEmptyValue[name]) { - didWarnForNewBooleanPropsWithEmptyValue[name] = true; - console.error( - 'Received an empty string for a boolean attribute `%s`. ' + - 'This will treat the attribute as if it were false. ' + - 'Either pass `false` to silence this warning, or ' + - 'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.', - name, - ); - } - } - // Boolean - if (value && typeof value !== 'function' && typeof value !== 'symbol') { - target.push( - attributeSeparator, - stringToChunk(name), - attributeEmptyString, - ); - } - return; - } - // fallthrough for new boolean props without the flag on default: if ( // shouldIgnoreAttribute