Cleanup enableNewBooleanProps (#28712)

This commit is contained in:
Sebastian Silbermann
2024-04-02 17:09:43 +02:00
committed by GitHub
parent 7659c4d9e0
commit 28fc980ef2
2 changed files with 16 additions and 26 deletions
@@ -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
+15 -24
View File
@@ -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