mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Merge bf1a93354f
into 6020386bbe
This commit is contained in:
commit
14b6815c6d
@ -130,10 +130,13 @@ export class DocumentCloner {
|
||||
});
|
||||
|
||||
documentClone.open();
|
||||
documentClone.write(`${serializeDoctype(document.doctype)}<html></html>`);
|
||||
if (document.doctype && document.doctype.nodeType === Node.DOCUMENT_TYPE_NODE) {
|
||||
const doctypeClone = document.doctype.cloneNode(false);
|
||||
documentClone.append(doctypeClone);
|
||||
}
|
||||
// Chrome scrolls the parent document for some reason after the write to the cloned window???
|
||||
restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
|
||||
documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement);
|
||||
documentClone.append(documentClone.adoptNode(this.documentElement));
|
||||
documentClone.close();
|
||||
|
||||
return iframeLoad;
|
||||
@ -568,32 +571,6 @@ export const copyCSSStyles = <T extends HTMLElement | SVGElement>(style: CSSStyl
|
||||
return target;
|
||||
};
|
||||
|
||||
const serializeDoctype = (doctype?: DocumentType | null): string => {
|
||||
let str = '';
|
||||
if (doctype) {
|
||||
str += '<!DOCTYPE ';
|
||||
if (doctype.name) {
|
||||
str += doctype.name;
|
||||
}
|
||||
|
||||
if (doctype.internalSubset) {
|
||||
str += doctype.internalSubset;
|
||||
}
|
||||
|
||||
if (doctype.publicId) {
|
||||
str += `"${doctype.publicId}"`;
|
||||
}
|
||||
|
||||
if (doctype.systemId) {
|
||||
str += `"${doctype.systemId}"`;
|
||||
}
|
||||
|
||||
str += '>';
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
const restoreOwnerScroll = (ownerDocument: Document | null, x: number, y: number) => {
|
||||
if (
|
||||
ownerDocument &&
|
||||
|
Loading…
Reference in New Issue
Block a user