Skip to content

Commit

Permalink
Revert "Less hacky, more verbose, more runtime impact"
Browse files Browse the repository at this point in the history
This reverts commit 133867b.
  • Loading branch information
Sebastian Silbermann committed Jan 17, 2024
1 parent 133867b commit 87a26b1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 46 deletions.
40 changes: 16 additions & 24 deletions packages/react-dom-bindings/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ function setProp(
case 'disableRemotePlayback':
case 'formNoValidate':
case 'hidden':
case 'inert':
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
case 'loop':
case 'noModule':
case 'noValidate':
Expand All @@ -724,18 +724,14 @@ function setProp(
case 'scoped':
case 'seamless':
case 'itemScope': {
const isNewBooleanProp = key === 'inert';
if (enableNewBooleanProps || !isNewBooleanProp) {
if (value && typeof value !== 'function' && typeof value !== 'symbol') {
domElement.setAttribute(key, '');
} else {
domElement.removeAttribute(key);
}
break;
if (value && typeof value !== 'function' && typeof value !== 'symbol') {
domElement.setAttribute(key, '');
} else {
domElement.removeAttribute(key);
}
break;
}
// Overloaded Boolean
// eslint-disable-next-line no-fallthrough -- Re-enable once enableNewBooleanProps is removed.
case 'capture':
case 'download': {
// An attribute that can be used as a flag as well as with a value.
Expand Down Expand Up @@ -2491,7 +2487,7 @@ function diffHydratedGenericElement(
case 'disableRemotePlayback':
case 'formNoValidate':
case 'hidden':
case 'inert':
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
case 'loop':
case 'noModule':
case 'noValidate':
Expand All @@ -2503,20 +2499,16 @@ function diffHydratedGenericElement(
case 'scoped':
case 'seamless':
case 'itemScope': {
const isNewBooleanProp = propKey === 'inert';
if (enableNewBooleanProps || !isNewBooleanProp) {
// Some of these need to be lower case to remove them from the extraAttributes list.
hydrateBooleanAttribute(
domElement,
propKey,
propKey.toLowerCase(),
value,
extraAttributes,
);
continue;
}
// Some of these need to be lower case to remove them from the extraAttributes list.
hydrateBooleanAttribute(
domElement,
propKey,
propKey.toLowerCase(),
value,
extraAttributes,
);
continue;
}
// eslint-disable-next-line no-fallthrough -- Re-enable once enableNewBooleanProps is removed.
case 'capture':
case 'download': {
hydrateOverloadedBooleanAttribute(
Expand Down
22 changes: 9 additions & 13 deletions packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ function pushAttribute(
case 'disableRemotePlayback':
case 'formNoValidate':
case 'hidden':
case 'inert':
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
case 'loop':
case 'noModule':
case 'noValidate':
Expand All @@ -1307,20 +1307,16 @@ function pushAttribute(
case 'scoped':
case 'seamless':
case 'itemScope': {
const isNewBooleanProp = name === 'inert';
if (enableNewBooleanProps || !isNewBooleanProp) {
// Boolean
if (value && typeof value !== 'function' && typeof value !== 'symbol') {
target.push(
attributeSeparator,
stringToChunk(name),
attributeEmptyString,
);
}
return;
// Boolean
if (value && typeof value !== 'function' && typeof value !== 'symbol') {
target.push(
attributeSeparator,
stringToChunk(name),
attributeEmptyString,
);
}
return;
}
// eslint-disable-next-line no-fallthrough -- Re-enable once enableNewBooleanProps is removed.
case 'capture':
case 'download': {
// Overloaded Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
case 'disableRemotePlayback':
case 'formNoValidate':
case 'hidden':
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
case 'loop':
case 'noModule':
case 'noValidate':
Expand All @@ -241,10 +242,6 @@ function validateProperty(tagName, name, value, eventRegistry) {
return true;
}
default: {
// TODO: Move into above cases once enableNewBooleanProps is removed.
if (enableNewBooleanProps && name === 'inert') {
return true;
}
const prefix = name.toLowerCase().slice(0, 5);
if (prefix === 'data-' || prefix === 'aria-') {
return true;
Expand Down Expand Up @@ -305,6 +302,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
case 'disableRemotePlayback':
case 'formNoValidate':
case 'hidden':
case enableNewBooleanProps ? 'inert' : 'formNoValidate':
case 'loop':
case 'noModule':
case 'noValidate':
Expand All @@ -318,11 +316,6 @@ function validateProperty(tagName, name, value, eventRegistry) {
case 'itemScope': {
break;
}
case 'inert':
if (enableNewBooleanProps) {
break;
}
// eslint-disable-next-line no-fallthrough -- not flagged after DCE
default: {
return true;
}
Expand Down

0 comments on commit 87a26b1

Please sign in to comment.