Skip to content

Commit f730469

Browse files
committed
fix logic around attribute seralization
1 parent ca01f35 commit f730469

File tree

1 file changed

+38
-32
lines changed

1 file changed

+38
-32
lines changed

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

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,6 +3928,10 @@ function writeStyleResourceAttributeInJS(
39283928
// Attribute renames
39293929
case 'className':
39303930
attributeName = 'class';
3931+
if (__DEV__) {
3932+
checkAttributeStringCoercion(value, attributeName);
3933+
}
3934+
attributeValue = '' + (value: any);
39313935
break;
39323936

39333937
// Booleans
@@ -3941,33 +3945,32 @@ function writeStyleResourceAttributeInJS(
39413945
// Santized URLs
39423946
case 'src':
39433947
case 'href': {
3948+
value = sanitizeURL(value);
39443949
if (__DEV__) {
39453950
checkAttributeStringCoercion(value, attributeName);
39463951
}
3947-
value = sanitizeURL(value);
3952+
attributeValue = '' + (value: any);
39483953
break;
39493954
}
39503955
default: {
3956+
if (
3957+
// shouldIgnoreAttribute
3958+
// We have already filtered out null/undefined and reserved words.
3959+
name.length > 2 &&
3960+
(name[0] === 'o' || name[0] === 'O') &&
3961+
(name[1] === 'n' || name[1] === 'N')
3962+
) {
3963+
return;
3964+
}
39513965
if (!isAttributeNameSafe(name)) {
39523966
return;
39533967
}
3968+
if (__DEV__) {
3969+
checkAttributeStringCoercion(value, attributeName);
3970+
}
3971+
attributeValue = '' + (value: any);
39543972
}
39553973
}
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);
39713974
writeChunk(destination, arrayInterstitial);
39723975
writeChunk(
39733976
destination,
@@ -4121,6 +4124,10 @@ function writeStyleResourceAttributeInAttr(
41214124
// Attribute renames
41224125
case 'className':
41234126
attributeName = 'class';
4127+
if (__DEV__) {
4128+
checkAttributeStringCoercion(value, attributeName);
4129+
}
4130+
attributeValue = '' + (value: any);
41244131
break;
41254132

41264133
// Booleans
@@ -4134,33 +4141,32 @@ function writeStyleResourceAttributeInAttr(
41344141
// Santized URLs
41354142
case 'src':
41364143
case 'href': {
4144+
value = sanitizeURL(value);
41374145
if (__DEV__) {
41384146
checkAttributeStringCoercion(value, attributeName);
41394147
}
4140-
value = sanitizeURL(value);
4148+
attributeValue = '' + (value: any);
41414149
break;
41424150
}
41434151
default: {
4152+
if (
4153+
// shouldIgnoreAttribute
4154+
// We have already filtered out null/undefined and reserved words.
4155+
name.length > 2 &&
4156+
(name[0] === 'o' || name[0] === 'O') &&
4157+
(name[1] === 'n' || name[1] === 'N')
4158+
) {
4159+
return;
4160+
}
41444161
if (!isAttributeNameSafe(name)) {
41454162
return;
41464163
}
4164+
if (__DEV__) {
4165+
checkAttributeStringCoercion(value, attributeName);
4166+
}
4167+
attributeValue = '' + (value: any);
41474168
}
41484169
}
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);
41644170
writeChunk(destination, arrayInterstitial);
41654171
writeChunk(
41664172
destination,

0 commit comments

Comments
 (0)