mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Update document-cloner.ts
This commit is contained in:
@@ -24,7 +24,6 @@ import {CSSParsedCounterDeclaration, CSSParsedPseudoDeclaration} from '../css/in
|
|||||||
import {getQuote} from '../css/property-descriptors/quotes';
|
import {getQuote} from '../css/property-descriptors/quotes';
|
||||||
import {Context} from '../core/context';
|
import {Context} from '../core/context';
|
||||||
import {DebuggerType, isDebugging} from '../core/debugger';
|
import {DebuggerType, isDebugging} from '../core/debugger';
|
||||||
import {serializeDoctype} from './serialize-doctype';
|
|
||||||
|
|
||||||
export interface CloneOptions {
|
export interface CloneOptions {
|
||||||
ignoreElements?: (element: Element) => boolean;
|
ignoreElements?: (element: Element) => boolean;
|
||||||
@@ -131,10 +130,14 @@ export class DocumentCloner {
|
|||||||
});
|
});
|
||||||
|
|
||||||
documentClone.open();
|
documentClone.open();
|
||||||
documentClone.write(serializeDoctype(document.doctype) as unknown as string);
|
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???
|
// Chrome scrolls the parent document for some reason after the write to the cloned window???
|
||||||
restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
|
restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
|
||||||
documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement);
|
documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement);
|
||||||
|
documentClone.append(documentClone.adoptNode(this.documentElement));
|
||||||
documentClone.close();
|
documentClone.close();
|
||||||
|
|
||||||
return iframeLoad;
|
return iframeLoad;
|
||||||
|
|||||||
Reference in New Issue
Block a user