Ignore function and symbol values on custom-elements on the server (#21157)

This commit is contained in:
Sebastian Markbåge
2021-03-31 21:17:42 -04:00
committed by GitHub
parent 588db2e1fc
commit a423a01223
2 changed files with 11 additions and 2 deletions

View File

@@ -71,7 +71,12 @@ export function createMarkupForCustomAttribute(
name: string,
value: mixed,
): string {
if (!isAttributeNameSafe(name) || value == null) {
if (
!isAttributeNameSafe(name) ||
value == null ||
typeof value === 'function' ||
typeof value === 'symbol'
) {
return '';
}
return name + '=' + quoteAttributeValueForBrowser(value);

View File

@@ -1070,7 +1070,11 @@ function pushStartCustomElement(
// Ignored. These are built-in to React on the client.
break;
default:
if (isAttributeNameSafe(propKey)) {
if (
isAttributeNameSafe(propKey) &&
typeof propValue !== 'function' &&
typeof propValue !== 'symbol'
) {
target.push(
attributeSeparator,
stringToChunk(propKey),