From 6cdf51af0a30027059d800b76ea02a2474603afd Mon Sep 17 00:00:00 2001 From: Josh Story Date: Wed, 8 Feb 2023 09:10:18 -0800 Subject: [PATCH] support innerHTML for title and style --- .../src/server/ReactDOMServerFormatConfig.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js b/packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js index cc1029c92d811..1cc2e946a54cf 100644 --- a/packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js +++ b/packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js @@ -1606,6 +1606,7 @@ function pushStyleImpl( target.push(startChunkForTag('style')); let children = null; + let innerHTML = null; for (const propKey in props) { if (hasOwnProperty.call(props, propKey)) { const propValue = props[propKey]; @@ -1617,9 +1618,8 @@ function pushStyleImpl( children = propValue; break; case 'dangerouslySetInnerHTML': - throw new Error( - '`dangerouslySetInnerHTML` does not make sense on .', - ); + innerHTML = propValue; + break; default: pushAttribute(target, propKey, propValue); break; @@ -1642,6 +1642,7 @@ function pushStyleImpl( // eslint-disable-next-line react-internal/safe-string-coercion target.push(stringToChunk(escapeTextForBrowser('' + child))); } + pushInnerHTML(target, innerHTML, children); target.push(endTag1, stringToChunk('style'), endTag2); return null; } @@ -1782,6 +1783,7 @@ function pushTitleImpl( target.push(startChunkForTag('title')); let children = null; + let innerHTML = null; for (const propKey in props) { if (hasOwnProperty.call(props, propKey)) { const propValue = props[propKey]; @@ -1793,9 +1795,8 @@ function pushTitleImpl( children = propValue; break; case 'dangerouslySetInnerHTML': - throw new Error( - '`dangerouslySetInnerHTML` does not make sense on <title>.', - ); + innerHTML = propValue; + break; default: pushAttribute(target, propKey, propValue); break; @@ -1818,6 +1819,7 @@ function pushTitleImpl( // eslint-disable-next-line react-internal/safe-string-coercion target.push(stringToChunk(escapeTextForBrowser('' + child))); } + pushInnerHTML(target, innerHTML, children); target.push(endTag1, stringToChunk('title'), endTag2); return null; }