Skip to content

Commit 670c7fa

Browse files
committed
Cleanup enableCustomElementPropertySupport flag
1 parent a73c345 commit 670c7fa

18 files changed

+63
-163
lines changed

packages/react-dom-bindings/src/client/DOMPropertyOperations.js

+6-16
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
*/
99

1010
import isAttributeNameSafe from '../shared/isAttributeNameSafe';
11-
import {
12-
enableTrustedTypesIntegration,
13-
enableCustomElementPropertySupport,
14-
} from 'shared/ReactFeatureFlags';
11+
import {enableTrustedTypesIntegration} from 'shared/ReactFeatureFlags';
1512
import {checkAttributeStringCoercion} from 'shared/CheckStringCoercion';
1613
import {getFiberCurrentPropsFromNode} from './ReactDOMComponentTree';
1714

@@ -73,25 +70,18 @@ export function getValueForAttributeOnCustomComponent(
7370
// it would be expected that they end up not having an attribute.
7471
return expected;
7572
case 'function':
76-
if (enableCustomElementPropertySupport) {
77-
return expected;
78-
}
79-
break;
73+
return expected;
8074
case 'boolean':
81-
if (enableCustomElementPropertySupport) {
82-
if (expected === false) {
83-
return expected;
84-
}
75+
if (expected === false) {
76+
return expected;
8577
}
8678
}
8779
return expected === undefined ? undefined : null;
8880
}
8981
const value = node.getAttribute(name);
9082

91-
if (enableCustomElementPropertySupport) {
92-
if (value === '' && expected === true) {
93-
return true;
94-
}
83+
if (value === '' && expected === true) {
84+
return true;
9585
}
9686

9787
if (__DEV__) {

packages/react-dom-bindings/src/client/ReactDOMComponent.js

+31-44
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ import sanitizeURL from '../shared/sanitizeURL';
6767

6868
import {
6969
enableBigIntSupport,
70-
enableCustomElementPropertySupport,
7170
disableIEWorkarounds,
7271
enableTrustedTypesIntegration,
7372
enableFilterEmptyStringAttributesDOM,
@@ -870,9 +869,7 @@ function setProp(
870869
}
871870
case 'innerText':
872871
case 'textContent':
873-
if (enableCustomElementPropertySupport) {
874-
break;
875-
}
872+
break;
876873
// Fall through
877874
default: {
878875
if (
@@ -983,25 +980,15 @@ function setPropOnCustomElement(
983980
}
984981
case 'innerText': // Properties
985982
case 'textContent':
986-
if (enableCustomElementPropertySupport) {
987-
break;
988-
}
983+
break;
989984
// Fall through
990985
default: {
991986
if (registrationNameDependencies.hasOwnProperty(key)) {
992987
if (__DEV__ && value != null && typeof value !== 'function') {
993988
warnForInvalidEventListener(key, value);
994989
}
995990
} else {
996-
if (enableCustomElementPropertySupport) {
997-
setValueForPropertyOnCustomComponent(domElement, key, value);
998-
} else {
999-
if (typeof value === 'boolean') {
1000-
// Special case before the new flag is on
1001-
value = '' + (value: any);
1002-
}
1003-
setValueForAttribute(domElement, key, value);
1004-
}
991+
setValueForPropertyOnCustomComponent(domElement, key, value);
1005992
}
1006993
}
1007994
}
@@ -2293,35 +2280,30 @@ function diffHydratedCustomComponent(
22932280
case 'isContentEditable':
22942281
case 'outerText':
22952282
case 'outerHTML':
2296-
if (enableCustomElementPropertySupport) {
2297-
extraAttributes.delete(propKey.toLowerCase());
2298-
if (__DEV__) {
2299-
console.error(
2300-
'Assignment to read-only property will result in a no-op: `%s`',
2301-
propKey,
2302-
);
2303-
}
2304-
continue;
2305-
}
2306-
// Fall through
2307-
case 'className':
2308-
if (enableCustomElementPropertySupport) {
2309-
// className is a special cased property on the server to render as an attribute.
2310-
extraAttributes.delete('class');
2311-
const serverValue = getValueForAttributeOnCustomComponent(
2312-
domElement,
2313-
'class',
2314-
value,
2315-
);
2316-
warnForPropDifference(
2317-
'className',
2318-
serverValue,
2319-
value,
2320-
serverDifferences,
2283+
extraAttributes.delete(propKey.toLowerCase());
2284+
if (__DEV__) {
2285+
console.error(
2286+
'Assignment to read-only property will result in a no-op: `%s`',
2287+
propKey,
23212288
);
2322-
continue;
23232289
}
2290+
continue;
23242291
// Fall through
2292+
case 'className':
2293+
// className is a special cased property on the server to render as an attribute.
2294+
extraAttributes.delete('class');
2295+
const serverValue = getValueForAttributeOnCustomComponent(
2296+
domElement,
2297+
'class',
2298+
value,
2299+
);
2300+
warnForPropDifference(
2301+
'className',
2302+
serverValue,
2303+
value,
2304+
serverDifferences,
2305+
);
2306+
continue;
23252307
default: {
23262308
// This is a DEV-only path
23272309
const hostContextDev: HostContextDev = (hostContext: any);
@@ -2335,12 +2317,17 @@ function diffHydratedCustomComponent(
23352317
} else {
23362318
extraAttributes.delete(propKey);
23372319
}
2338-
const serverValue = getValueForAttributeOnCustomComponent(
2320+
const valueOnCustomComponent = getValueForAttributeOnCustomComponent(
23392321
domElement,
23402322
propKey,
23412323
value,
23422324
);
2343-
warnForPropDifference(propKey, serverValue, value, serverDifferences);
2325+
warnForPropDifference(
2326+
propKey,
2327+
valueOnCustomComponent,
2328+
value,
2329+
serverDifferences,
2330+
);
23442331
}
23452332
}
23462333
}

packages/react-dom-bindings/src/events/plugins/ChangeEventPlugin.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ import {updateValueIfChanged} from '../../client/inputValueTracking';
2626
import {setDefaultValue} from '../../client/ReactDOMInput';
2727
import {enqueueStateRestore} from '../ReactDOMControlledComponent';
2828

29-
import {
30-
disableInputAttributeSyncing,
31-
enableCustomElementPropertySupport,
32-
} from 'shared/ReactFeatureFlags';
29+
import {disableInputAttributeSyncing} from 'shared/ReactFeatureFlags';
3330
import {batchedUpdates} from '../ReactDOMUpdateBatching';
3431
import {
3532
processDispatchQueue,
@@ -311,7 +308,6 @@ function extractEvents(
311308
} else if (shouldUseClickEvent(targetNode)) {
312309
getTargetInstFunc = getTargetInstForClickEvent;
313310
} else if (
314-
enableCustomElementPropertySupport &&
315311
targetInst &&
316312
isCustomElement(targetInst.elementType, targetInst.memoizedProps)
317313
) {

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js

+9-14
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {Children} from 'react';
3030
import {
3131
enableBigIntSupport,
3232
enableFilterEmptyStringAttributesDOM,
33-
enableCustomElementPropertySupport,
3433
enableFizzExternalRuntime,
3534
enableNewBooleanProps,
3635
} from 'shared/ReactFeatureFlags';
@@ -3342,26 +3341,22 @@ function pushStartCustomElement(
33423341
// Ignored. These are built-in to React on the client.
33433342
break;
33443343
case 'className':
3345-
if (enableCustomElementPropertySupport) {
3346-
// className gets rendered as class on the client, so it should be
3347-
// rendered as class on the server.
3348-
attributeName = 'class';
3349-
}
3344+
// className gets rendered as class on the client, so it should be
3345+
// rendered as class on the server.
3346+
attributeName = 'class';
33503347
// intentional fallthrough
33513348
default:
33523349
if (
33533350
isAttributeNameSafe(propKey) &&
33543351
typeof propValue !== 'function' &&
33553352
typeof propValue !== 'symbol'
33563353
) {
3357-
if (enableCustomElementPropertySupport) {
3358-
if (propValue === false) {
3359-
continue;
3360-
} else if (propValue === true) {
3361-
propValue = '';
3362-
} else if (typeof propValue === 'object') {
3363-
continue;
3364-
}
3354+
if (propValue === false) {
3355+
continue;
3356+
} else if (propValue === true) {
3357+
propValue = '';
3358+
} else if (typeof propValue === 'object') {
3359+
continue;
33653360
}
33663361
target.push(
33673362
attributeSeparator,

packages/react-dom-bindings/src/shared/ReactDOMUnknownPropertyHook.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ import {ATTRIBUTE_NAME_CHAR} from './isAttributeNameSafe';
99
import isCustomElement from './isCustomElement';
1010
import possibleStandardNames from './possibleStandardNames';
1111
import hasOwnProperty from 'shared/hasOwnProperty';
12-
import {
13-
enableCustomElementPropertySupport,
14-
enableNewBooleanProps,
15-
} from 'shared/ReactFeatureFlags';
12+
import {enableNewBooleanProps} from 'shared/ReactFeatureFlags';
1613

1714
const warnedProperties = {};
1815
const EVENT_NAME_REGEX = /^on./;
@@ -189,9 +186,7 @@ function validateProperty(tagName, name, value, eventRegistry) {
189186
}
190187
case 'innerText': // Properties
191188
case 'textContent':
192-
if (enableCustomElementPropertySupport) {
193-
return true;
194-
}
189+
return true;
195190
}
196191

197192
switch (typeof value) {

0 commit comments

Comments
 (0)