Skip to content

Commit

Permalink
Ignore function and symbol values on custom-elements on the server (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Apr 1, 2021
1 parent 588db2e commit a423a01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/react-dom/src/server/DOMMarkupOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion packages/react-dom/src/server/ReactDOMServerFormatConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit a423a01

Please sign in to comment.