Skip to content

Commit 6cdf51a

Browse files
committed
support innerHTML for title and style
1 parent 6c56d8d commit 6cdf51a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,7 @@ function pushStyleImpl(
16061606
target.push(startChunkForTag('style'));
16071607

16081608
let children = null;
1609+
let innerHTML = null;
16091610
for (const propKey in props) {
16101611
if (hasOwnProperty.call(props, propKey)) {
16111612
const propValue = props[propKey];
@@ -1617,9 +1618,8 @@ function pushStyleImpl(
16171618
children = propValue;
16181619
break;
16191620
case 'dangerouslySetInnerHTML':
1620-
throw new Error(
1621-
'`dangerouslySetInnerHTML` does not make sense on <title>.',
1622-
);
1621+
innerHTML = propValue;
1622+
break;
16231623
default:
16241624
pushAttribute(target, propKey, propValue);
16251625
break;
@@ -1642,6 +1642,7 @@ function pushStyleImpl(
16421642
// eslint-disable-next-line react-internal/safe-string-coercion
16431643
target.push(stringToChunk(escapeTextForBrowser('' + child)));
16441644
}
1645+
pushInnerHTML(target, innerHTML, children);
16451646
target.push(endTag1, stringToChunk('style'), endTag2);
16461647
return null;
16471648
}
@@ -1782,6 +1783,7 @@ function pushTitleImpl(
17821783
target.push(startChunkForTag('title'));
17831784

17841785
let children = null;
1786+
let innerHTML = null;
17851787
for (const propKey in props) {
17861788
if (hasOwnProperty.call(props, propKey)) {
17871789
const propValue = props[propKey];
@@ -1793,9 +1795,8 @@ function pushTitleImpl(
17931795
children = propValue;
17941796
break;
17951797
case 'dangerouslySetInnerHTML':
1796-
throw new Error(
1797-
'`dangerouslySetInnerHTML` does not make sense on <title>.',
1798-
);
1798+
innerHTML = propValue;
1799+
break;
17991800
default:
18001801
pushAttribute(target, propKey, propValue);
18011802
break;
@@ -1818,6 +1819,7 @@ function pushTitleImpl(
18181819
// eslint-disable-next-line react-internal/safe-string-coercion
18191820
target.push(stringToChunk(escapeTextForBrowser('' + child)));
18201821
}
1822+
pushInnerHTML(target, innerHTML, children);
18211823
target.push(endTag1, stringToChunk('title'), endTag2);
18221824
return null;
18231825
}

0 commit comments

Comments
 (0)