Skip to content

Commit 660a689

Browse files
committed
cleanup enableCustomElementPropertySupport flag
1 parent 67cc9ba commit 660a689

18 files changed

+58
-159
lines changed

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

Lines changed: 7 additions & 18 deletions
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

@@ -69,29 +66,21 @@ export function getValueForAttributeOnCustomComponent(
6966
switch (typeof expected) {
7067
case 'symbol':
7168
case 'object':
72-
// Symbols and objects are ignored when they're emitted so
69+
case 'function':
70+
// Symbols, objects, and functions are ignored when they're emitted so
7371
// it would be expected that they end up not having an attribute.
7472
return expected;
75-
case 'function':
76-
if (enableCustomElementPropertySupport) {
77-
return expected;
78-
}
79-
break;
8073
case 'boolean':
81-
if (enableCustomElementPropertySupport) {
82-
if (expected === false) {
83-
return expected;
84-
}
74+
if (expected === false) {
75+
return expected;
8576
}
8677
}
8778
return expected === undefined ? undefined : null;
8879
}
8980
const value = node.getAttribute(name);
9081

91-
if (enableCustomElementPropertySupport) {
92-
if (value === '' && expected === true) {
93-
return true;
94-
}
82+
if (value === '' && expected === true) {
83+
return true;
9584
}
9685

9786
if (__DEV__) {

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

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ import {validateProperties as validateUnknownProperties} from '../shared/ReactDO
6666
import sanitizeURL from '../shared/sanitizeURL';
6767

6868
import {
69-
enableCustomElementPropertySupport,
7069
enableClientRenderFallbackOnTextMismatch,
7170
enableFormActions,
7271
enableHostSingletons,
@@ -884,9 +883,7 @@ function setProp(
884883
}
885884
case 'innerText':
886885
case 'textContent':
887-
if (enableCustomElementPropertySupport) {
888-
break;
889-
}
886+
break;
890887
// Fall through
891888
default: {
892889
if (
@@ -992,25 +989,15 @@ function setPropOnCustomElement(
992989
}
993990
case 'innerText': // Properties
994991
case 'textContent':
995-
if (enableCustomElementPropertySupport) {
996-
break;
997-
}
992+
break;
998993
// Fall through
999994
default: {
1000995
if (registrationNameDependencies.hasOwnProperty(key)) {
1001996
if (__DEV__ && value != null && typeof value !== 'function') {
1002997
warnForInvalidEventListener(key, value);
1003998
}
1004999
} else {
1005-
if (enableCustomElementPropertySupport) {
1006-
setValueForPropertyOnCustomComponent(domElement, key, value);
1007-
} else {
1008-
if (typeof value === 'boolean') {
1009-
// Special case before the new flag is on
1010-
value = '' + (value: any);
1011-
}
1012-
setValueForAttribute(domElement, key, value);
1013-
}
1000+
setValueForPropertyOnCustomComponent(domElement, key, value);
10141001
}
10151002
}
10161003
}
@@ -2213,30 +2200,28 @@ function diffHydratedCustomComponent(
22132200
case 'offsetHeight':
22142201
case 'isContentEditable':
22152202
case 'outerText':
2216-
case 'outerHTML':
2217-
if (enableCustomElementPropertySupport) {
2218-
extraAttributes.delete(propKey.toLowerCase());
2219-
if (__DEV__) {
2220-
console.error(
2221-
'Assignment to read-only property will result in a no-op: `%s`',
2222-
propKey,
2223-
);
2224-
}
2225-
continue;
2226-
}
2227-
// Fall through
2228-
case 'className':
2229-
if (enableCustomElementPropertySupport) {
2230-
// className is a special cased property on the server to render as an attribute.
2231-
extraAttributes.delete('class');
2232-
const serverValue = getValueForAttributeOnCustomComponent(
2233-
domElement,
2234-
'class',
2235-
value,
2203+
case 'outerHTML': {
2204+
extraAttributes.delete(propKey.toLowerCase());
2205+
if (__DEV__) {
2206+
console.error(
2207+
'Assignment to read-only property will result in a no-op: `%s`',
2208+
propKey,
22362209
);
2237-
warnForPropDifference('className', serverValue, value);
2238-
continue;
22392210
}
2211+
continue;
2212+
}
2213+
// Fall through
2214+
case 'className': {
2215+
// className is a special cased property on the server to render as an attribute.
2216+
extraAttributes.delete('class');
2217+
const serverValue = getValueForAttributeOnCustomComponent(
2218+
domElement,
2219+
'class',
2220+
value,
2221+
);
2222+
warnForPropDifference('className', serverValue, value);
2223+
continue;
2224+
}
22402225
// Fall through
22412226
default: {
22422227
// This is a DEV-only path

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

Lines changed: 1 addition & 5 deletions
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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {Children} from 'react';
2828

2929
import {
3030
enableFilterEmptyStringAttributesDOM,
31-
enableCustomElementPropertySupport,
3231
enableFloat,
3332
enableFormActions,
3433
enableFizzExternalRuntime,
@@ -3156,26 +3155,22 @@ function pushStartCustomElement(
31563155
// Ignored. These are built-in to React on the client.
31573156
break;
31583157
case 'className':
3159-
if (enableCustomElementPropertySupport) {
3160-
// className gets rendered as class on the client, so it should be
3161-
// rendered as class on the server.
3162-
attributeName = 'class';
3163-
}
3158+
// className gets rendered as class on the client, so it should be
3159+
// rendered as class on the server.
3160+
attributeName = 'class';
31643161
// intentional fallthrough
31653162
default:
31663163
if (
31673164
isAttributeNameSafe(propKey) &&
31683165
typeof propValue !== 'function' &&
31693166
typeof propValue !== 'symbol'
31703167
) {
3171-
if (enableCustomElementPropertySupport) {
3172-
if (propValue === false) {
3173-
continue;
3174-
} else if (propValue === true) {
3175-
propValue = '';
3176-
} else if (typeof propValue === 'object') {
3177-
continue;
3178-
}
3168+
if (propValue === false) {
3169+
continue;
3170+
} else if (propValue === true) {
3171+
propValue = '';
3172+
} else if (typeof propValue === 'object') {
3173+
continue;
31793174
}
31803175
target.push(
31813176
attributeSeparator,

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

Lines changed: 4 additions & 8 deletions
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-
enableFormActions,
15-
} from 'shared/ReactFeatureFlags';
12+
import {enableFormActions} from 'shared/ReactFeatureFlags';
1613

1714
const warnedProperties = {};
1815
const EVENT_NAME_REGEX = /^on./;
@@ -190,10 +187,9 @@ function validateProperty(tagName, name, value, eventRegistry) {
190187
return true;
191188
}
192189
case 'innerText': // Properties
193-
case 'textContent':
194-
if (enableCustomElementPropertySupport) {
195-
return true;
196-
}
190+
case 'textContent': {
191+
return true;
192+
}
197193
}
198194

199195
switch (typeof value) {

0 commit comments

Comments
 (0)