Properly handle rendering into document when comparing markup
This commit is contained in:
parent
0249adf3db
commit
1316160b86
|
@ -880,9 +880,20 @@ var ReactMount = {
|
|||
checksum
|
||||
);
|
||||
|
||||
var normalizer = document.createElement('div');
|
||||
normalizer.innerHTML = markup;
|
||||
var normalizedMarkup = normalizer.innerHTML;
|
||||
// because rootMarkup is retrieved from the DOM, various normalizations
|
||||
// will have occurred which will not be present in `markup`. Here,
|
||||
// insert markup into a <div> or <iframe> depending on the container
|
||||
// type to perform the same normalizations before comparing.
|
||||
if (container.nodeType === ELEMENT_NODE_TYPE) {
|
||||
var normalizer = document.createElement('div');
|
||||
normalizer.innerHTML = markup;
|
||||
var normalizedMarkup = normalizer.innerHTML;
|
||||
} else {
|
||||
var normalizer = document.createElement('iframe');
|
||||
document.body.appendChild(normalizer);
|
||||
normalizer.contentDocument.write(markup);
|
||||
var normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
|
||||
}
|
||||
|
||||
var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
|
||||
var difference = ' (client) ' +
|
||||
|
|
Loading…
Reference in New Issue