Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 1133711

Browse files
committed
Manually apply the fix from facebook#4324 to version 0.13.3
1 parent 668d6a3 commit 1133711

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/browser/ui/ReactMount.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,29 @@ var ReactMount = {
811811
checksum
812812
);
813813

814-
var diffIndex = firstDifferenceIndex(markup, rootMarkup);
814+
var normalizedMarkup = markup;
815+
if (__DEV__) {
816+
// because rootMarkup is retrieved from the DOM, various normalizations
817+
// will have occurred which will not be present in `markup`. Here,
818+
// insert markup into a <div> or <iframe> depending on the container
819+
// type to perform the same normalizations before comparing.
820+
var normalizer;
821+
if (container.nodeType === ELEMENT_NODE_TYPE) {
822+
normalizer = document.createElement('div');
823+
normalizer.innerHTML = markup;
824+
normalizedMarkup = normalizer.innerHTML;
825+
} else {
826+
normalizer = document.createElement('iframe');
827+
document.body.appendChild(normalizer);
828+
normalizer.contentDocument.write(markup);
829+
normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
830+
document.body.removeChild(normalizer);
831+
}
832+
}
833+
834+
var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
815835
var difference = ' (client) ' +
816-
markup.substring(diffIndex - 20, diffIndex + 20) +
836+
normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) +
817837
'\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
818838

819839
invariant(

0 commit comments

Comments
 (0)