Skip to content

Commit 442eb21

Browse files
authored
Allow dangerouslySetInnerHTML in <option> (#21373)
1 parent 9a130e1 commit 442eb21

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ function pushStartOption(
691691
let children = null;
692692
let value = null;
693693
let selected = null;
694+
let innerHTML = null;
694695
for (const propKey in props) {
695696
if (hasOwnProperty.call(props, propKey)) {
696697
const propValue = props[propKey];
@@ -716,10 +717,8 @@ function pushStartOption(
716717
}
717718
break;
718719
case 'dangerouslySetInnerHTML':
719-
invariant(
720-
false,
721-
'`dangerouslySetInnerHTML` does not work on <option>.',
722-
);
720+
innerHTML = propValue;
721+
break;
723722
// eslint-disable-next-line-no-fallthrough
724723
case 'value':
725724
value = propValue;
@@ -760,6 +759,7 @@ function pushStartOption(
760759
}
761760

762761
target.push(endOfStartTag);
762+
pushInnerHTML(target, innerHTML, children);
763763
return children;
764764
}
765765

0 commit comments

Comments
 (0)