From 7b8f7695a7a8bfbcbae2d802e5d79289067616ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Wed, 31 Mar 2021 21:17:42 -0400 Subject: [PATCH] Ignore function and symbol values on custom-elements on the server (#21157) --- packages/react-dom/src/server/DOMMarkupOperations.js | 7 ++++++- .../react-dom/src/server/ReactDOMServerFormatConfig.js | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/react-dom/src/server/DOMMarkupOperations.js b/packages/react-dom/src/server/DOMMarkupOperations.js index 7306d9393be56..3cddbb493e07e 100644 --- a/packages/react-dom/src/server/DOMMarkupOperations.js +++ b/packages/react-dom/src/server/DOMMarkupOperations.js @@ -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); diff --git a/packages/react-dom/src/server/ReactDOMServerFormatConfig.js b/packages/react-dom/src/server/ReactDOMServerFormatConfig.js index 2a034963f48af..62f6d3ca56550 100644 --- a/packages/react-dom/src/server/ReactDOMServerFormatConfig.js +++ b/packages/react-dom/src/server/ReactDOMServerFormatConfig.js @@ -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),