Skip to content

Commit ea499ef

Browse files
committed
Revert "Fix logic around attribute seralization (facebook#26526)"
This reverts commit 4a1cc2d.
1 parent c6baac3 commit ea499ef

File tree

1 file changed

+38
-46
lines changed

1 file changed

+38
-46
lines changed

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

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3926,51 +3926,48 @@ function writeStyleResourceAttributeInJS(
39263926
return;
39273927

39283928
// Attribute renames
3929-
case 'className': {
3929+
case 'className':
39303930
attributeName = 'class';
3931-
if (__DEV__) {
3932-
checkAttributeStringCoercion(value, attributeName);
3933-
}
3934-
attributeValue = '' + (value: any);
39353931
break;
3936-
}
3932+
39373933
// Booleans
3938-
case 'hidden': {
3934+
case 'hidden':
39393935
if (value === false) {
39403936
return;
39413937
}
39423938
attributeValue = '';
39433939
break;
3944-
}
3940+
39453941
// Santized URLs
39463942
case 'src':
39473943
case 'href': {
3948-
value = sanitizeURL(value);
39493944
if (__DEV__) {
39503945
checkAttributeStringCoercion(value, attributeName);
39513946
}
3952-
attributeValue = '' + (value: any);
3947+
value = sanitizeURL(value);
39533948
break;
39543949
}
39553950
default: {
3956-
if (
3957-
// unrecognized event handlers are not SSR'd and we (apparently)
3958-
// use on* as hueristic for these handler props
3959-
name.length > 2 &&
3960-
(name[0] === 'o' || name[0] === 'O') &&
3961-
(name[1] === 'n' || name[1] === 'N')
3962-
) {
3963-
return;
3964-
}
39653951
if (!isAttributeNameSafe(name)) {
39663952
return;
39673953
}
3968-
if (__DEV__) {
3969-
checkAttributeStringCoercion(value, attributeName);
3970-
}
3971-
attributeValue = '' + (value: any);
39723954
}
39733955
}
3956+
3957+
if (
3958+
// shouldIgnoreAttribute
3959+
// We have already filtered out null/undefined and reserved words.
3960+
name.length > 2 &&
3961+
(name[0] === 'o' || name[0] === 'O') &&
3962+
(name[1] === 'n' || name[1] === 'N')
3963+
) {
3964+
return;
3965+
}
3966+
3967+
if (__DEV__) {
3968+
checkAttributeStringCoercion(value, attributeName);
3969+
}
3970+
attributeValue = '' + (value: any);
39743971
writeChunk(destination, arrayInterstitial);
39753972
writeChunk(
39763973
destination,
@@ -4122,53 +4119,48 @@ function writeStyleResourceAttributeInAttr(
41224119
return;
41234120

41244121
// Attribute renames
4125-
case 'className': {
4122+
case 'className':
41264123
attributeName = 'class';
4127-
if (__DEV__) {
4128-
checkAttributeStringCoercion(value, attributeName);
4129-
}
4130-
attributeValue = '' + (value: any);
41314124
break;
4132-
}
41334125

41344126
// Booleans
4135-
case 'hidden': {
4127+
case 'hidden':
41364128
if (value === false) {
41374129
return;
41384130
}
41394131
attributeValue = '';
41404132
break;
4141-
}
41424133

41434134
// Santized URLs
41444135
case 'src':
41454136
case 'href': {
4146-
value = sanitizeURL(value);
41474137
if (__DEV__) {
41484138
checkAttributeStringCoercion(value, attributeName);
41494139
}
4150-
attributeValue = '' + (value: any);
4140+
value = sanitizeURL(value);
41514141
break;
41524142
}
41534143
default: {
4154-
if (
4155-
// unrecognized event handlers are not SSR'd and we (apparently)
4156-
// use on* as hueristic for these handler props
4157-
name.length > 2 &&
4158-
(name[0] === 'o' || name[0] === 'O') &&
4159-
(name[1] === 'n' || name[1] === 'N')
4160-
) {
4161-
return;
4162-
}
41634144
if (!isAttributeNameSafe(name)) {
41644145
return;
41654146
}
4166-
if (__DEV__) {
4167-
checkAttributeStringCoercion(value, attributeName);
4168-
}
4169-
attributeValue = '' + (value: any);
41704147
}
41714148
}
4149+
4150+
if (
4151+
// shouldIgnoreAttribute
4152+
// We have already filtered out null/undefined and reserved words.
4153+
name.length > 2 &&
4154+
(name[0] === 'o' || name[0] === 'O') &&
4155+
(name[1] === 'n' || name[1] === 'N')
4156+
) {
4157+
return;
4158+
}
4159+
4160+
if (__DEV__) {
4161+
checkAttributeStringCoercion(value, attributeName);
4162+
}
4163+
attributeValue = '' + (value: any);
41724164
writeChunk(destination, arrayInterstitial);
41734165
writeChunk(
41744166
destination,

0 commit comments

Comments
 (0)