Permalink
Browse files

Removing use of replaceChild and adoptNode, would cause original docu…

…ment to lose style context.

Instead, we now just document.write the outerHTML of the cloned window
  • Loading branch information...
cloakedninjas committed Jan 15, 2015
1 parent 0df71b3 commit 0bfd4a4e1fc92f15ec96a77e38de28729d9548e9
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/core.js
View
@@ -166,10 +166,12 @@ function createWindowClone(ownerDocument, containerDocument, width, height, opti
var y = ownerDocument.defaultView.pageYOffset;
documentClone.open();
documentClone.write("<!DOCTYPE html><html></html>");
// Chrome scrolls the parent document for some reason after the write to the cloned window???
restoreOwnerScroll(ownerDocument, x, y);
documentClone.replaceChild(options.javascriptEnabled === true ? documentClone.adoptNode(documentElement) : removeScriptNodes(documentClone.adoptNode(documentElement)), documentClone.documentElement);
var docToInsert = options.javascriptEnabled === true ? documentElement : removeScriptNodes(documentElement);
documentClone.write(docToInsert.outerHTML);
documentClone.close();
});
}

0 comments on commit 0bfd4a4

Please sign in to comment.