Only perform expensive checks in __DEV__, clean up after inserted iframe
Eric O'Connell committed
Jul 9, 2015 at 15:49 UTC
d2e8449bf03ccec1c3764c136401652dc844e51a
1 file changed
+18
-14
src/renderers/dom/client/ReactMount.js
+18
-14
@@ -880,20 +880,24 @@ var ReactMount = {
880
checksum
881
);
882
883
- // because rootMarkup is retrieved from the DOM, various normalizations
884
- // will have occurred which will not be present in `markup`. Here,
885
- // insert markup into a <div> or <iframe> depending on the container
886
- // type to perform the same normalizations before comparing.
887
- var normalizer, normalizedMarkup;
888
- if (container.nodeType === ELEMENT_NODE_TYPE) {
889
- normalizer = document.createElement('div');
890
- normalizer.innerHTML = markup;
891
- normalizedMarkup = normalizer.innerHTML;
892
- } else {
893
- normalizer = document.createElement('iframe');
894
- document.body.appendChild(normalizer);
895
- normalizer.contentDocument.write(markup);
896
- normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
883
+ var normalizedMarkup = markup;
884
+ if (__DEV__) {
885
+ // because rootMarkup is retrieved from the DOM, various normalizations
886
+ // will have occurred which will not be present in `markup`. Here,
887
+ // insert markup into a <div> or <iframe> depending on the container
888
+ // type to perform the same normalizations before comparing.
889
+ var normalizer;
890
+ if (container.nodeType === ELEMENT_NODE_TYPE) {
891
+ normalizer = document.createElement('div');
892
+ normalizer.innerHTML = markup;
893
+ normalizedMarkup = normalizer.innerHTML;
894
+ } else {
895
+ normalizer = document.createElement('iframe');
896
+ document.body.appendChild(normalizer);
897
+ normalizer.contentDocument.write(markup);
898
+ normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
899
+ document.body.removeChild(normalizer);
900
+ }
901
}
902
903
var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);