@samitouri / QOS-React / commits / 442eb21e0e

Allow dangerouslySetInnerHTML in <option> (#21373)

Sebastian Markbåge committed May 4, 2021 at 10:45 UTC 442eb21e0e6541460157782d18edea1383ed62fd
1 file changed +4 -4
packages/react-dom/src/server/ReactDOMServerFormatConfig.js
+4 -4
@@ -691,6 +691,7 @@ function pushStartOption(
691 let children = null;
692 let value = null;
693 let selected = null;
694 + let innerHTML = null;
695 for (const propKey in props) {
696 if (hasOwnProperty.call(props, propKey)) {
697 const propValue = props[propKey];
@@ -716,10 +717,8 @@ function pushStartOption(
717 }
718 break;
719 case 'dangerouslySetInnerHTML':
719 - invariant(
720 - false,
721 - '`dangerouslySetInnerHTML` does not work on <option>.',
722 - );
720 + innerHTML = propValue;
721 + break;
722 // eslint-disable-next-line-no-fallthrough
723 case 'value':
724 value = propValue;
@@ -760,6 +759,7 @@ function pushStartOption(
759 }
760
761 target.push(endOfStartTag);
762 + pushInnerHTML(target, innerHTML, children);
763 return children;
764 }
765