Ignore function and symbol values on custom-elements on the server (#21157)
Sebastian Markbåge committed
Mar 31, 2021 at 21:17 UTC
a423a01223785a8bc4dcd55f2a0288200b033eee
2 files changed
+11
-2
packages/react-dom/src/server/DOMMarkupOperations.js
+6
-1
@@ -71,7 +71,12 @@ export function createMarkupForCustomAttribute(
71
name: string,
72
value: mixed,
73
): string {
74
- if (!isAttributeNameSafe(name) || value == null) {
74
+ if (
75
+ !isAttributeNameSafe(name) ||
76
+ value == null ||
77
+ typeof value === 'function' ||
78
+ typeof value === 'symbol'
79
+ ) {
80
return '';
81
}
82
return name + '=' + quoteAttributeValueForBrowser(value);
packages/react-dom/src/server/ReactDOMServerFormatConfig.js
+5
-1
@@ -1070,7 +1070,11 @@ function pushStartCustomElement(
1070
// Ignored. These are built-in to React on the client.
1071
break;
1072
default:
1073
- if (isAttributeNameSafe(propKey)) {
1073
+ if (
1074
+ isAttributeNameSafe(propKey) &&
1075
+ typeof propValue !== 'function' &&
1076
+ typeof propValue !== 'symbol'
1077
+ ) {
1078
target.push(
1079
attributeSeparator,
1080
stringToChunk(propKey),