Skip to content

Commit 2484117

Browse files
committed
Remove shouldSetAttribute()
Its naming was confusing and it was used all over the place instead of more specific checks. Now that we only have one call site, we might as well inline and get rid of it.
1 parent ec83eac commit 2484117

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

packages/react-dom/src/client/ReactDOMFiberComponent.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ import setTextContent from './setTextContent';
2424
import {listenTo, trapBubbledEvent} from '../events/ReactBrowserEventEmitter';
2525
import * as CSSPropertyOperations from '../shared/CSSPropertyOperations';
2626
import {Namespaces, getIntrinsicNamespace} from '../shared/DOMNamespaces';
27-
import {getPropertyInfo, shouldSetAttribute} from '../shared/DOMProperty';
27+
import {
28+
getPropertyInfo,
29+
shouldSkipAttribute,
30+
shouldTreatAttributeValueAsNull,
31+
} from '../shared/DOMProperty';
2832
import assertValidProps from '../shared/assertValidProps';
2933
import {DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE} from '../shared/HTMLNodeType';
3034
import isCustomComponent from '../shared/isCustomComponent';
@@ -1000,7 +1004,14 @@ export function diffHydratedProperties(
10001004
if (nextProp !== serverValue) {
10011005
warnForPropDifference(propKey, serverValue, nextProp);
10021006
}
1003-
} else if (shouldSetAttribute(propKey, nextProp, isCustomComponentTag)) {
1007+
} else if (
1008+
!shouldSkipAttribute(propKey, isCustomComponentTag) &&
1009+
!shouldTreatAttributeValueAsNull(
1010+
propKey,
1011+
nextProp,
1012+
isCustomComponentTag,
1013+
)
1014+
) {
10041015
if ((propertyInfo = getPropertyInfo(propKey))) {
10051016
// $FlowFixMe - Should be inferred as not undefined.
10061017
extraAttributeNames.delete(propertyInfo.attributeName);

packages/react-dom/src/server/DOMMarkupOperations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function createMarkupForRoot() {
4141
* @return {?string} Markup string, or null if the property was invalid.
4242
*/
4343
export function createMarkupForProperty(name, value) {
44-
if (name !== 'style' && shouldSkipAttribute(name)) {
44+
if (name !== 'style' && shouldSkipAttribute(name, false)) {
4545
return '';
4646
}
4747
if (shouldTreatAttributeValueAsNull(name, value, false)) {

packages/react-dom/src/shared/DOMProperty.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,6 @@ export function shouldTreatAttributeValueAsNull(
234234
return false;
235235
}
236236

237-
export function shouldSetAttribute(name, value, isCustomComponentTag) {
238-
if (shouldSkipAttribute(name, isCustomComponentTag)) {
239-
return false;
240-
}
241-
if (shouldTreatAttributeValueAsNull(name, value, isCustomComponentTag)) {
242-
return false;
243-
}
244-
return true;
245-
}
246-
247237
export function getPropertyInfo(name) {
248238
return properties.hasOwnProperty(name) ? properties[name] : null;
249239
}

0 commit comments

Comments
 (0)