From fccebad780ff06d65a26712089dc6c4af4b4a6eb Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Wed, 7 Dec 2016 17:20:57 -0800 Subject: [PATCH] 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. --- src/renderers/dom/stack/client/ReactDOMComponent.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/renderers/dom/stack/client/ReactDOMComponent.js b/src/renderers/dom/stack/client/ReactDOMComponent.js index 0992b42f08..13f61ae8c4 100644 --- a/src/renderers/dom/stack/client/ReactDOMComponent.js +++ b/src/renderers/dom/stack/client/ReactDOMComponent.js @@ -787,8 +787,9 @@ ReactDOMComponent.Mixin = { // Intentional use of != to avoid catching zero/false. var innerHTML = props.dangerouslySetInnerHTML; if (innerHTML != null) { - if (innerHTML.__html != null) { - DOMLazyTree.queueHTML(lazyTree, innerHTML.__html); + const innerHTMLContent = innerHTML.__html; + if (innerHTMLContent != null && innerHTMLContent !== '') { + DOMLazyTree.queueHTML(lazyTree, innerHTMLContent); } } else { var contentToUse =