Don't set innerHTML if content is empty (#8526)
From D4296244: > Each [...] had a component with innerHTML = '', causing us to go into HTML parsing code in the browser. Doing this takes 0.03ms per parse call which was 10x slower than skipping it.
Ben Alpert committed
Dec 7, 2016 at 17:20 UTC
fccebad780ff06d65a26712089dc6c4af4b4a6eb
1 file changed
+3
-2
src/renderers/dom/stack/client/ReactDOMComponent.js
+3
-2
@@ -787,8 +787,9 @@ ReactDOMComponent.Mixin = {
787
// Intentional use of != to avoid catching zero/false.
788
var innerHTML = props.dangerouslySetInnerHTML;
789
if (innerHTML != null) {
790
- if (innerHTML.__html != null) {
791
- DOMLazyTree.queueHTML(lazyTree, innerHTML.__html);
790
+ const innerHTMLContent = innerHTML.__html;
791
+ if (innerHTMLContent != null && innerHTMLContent !== '') {
792
+ DOMLazyTree.queueHTML(lazyTree, innerHTMLContent);
793
}
794
} else {
795
var contentToUse =