mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Re-introduce onclone option (Fix #1434)
This commit is contained in:
17
src/Clone.js
17
src/Clone.js
@ -611,14 +611,21 @@ export const cloneWindow = (
|
||||
documentClone.documentElement.style.left = -bounds.left + 'px';
|
||||
documentClone.documentElement.style.position = 'absolute';
|
||||
}
|
||||
|
||||
const result = Promise.resolve([
|
||||
cloneIframeContainer,
|
||||
cloner.clonedReferenceElement,
|
||||
cloner.resourceLoader
|
||||
]);
|
||||
|
||||
const onclone = options.onclone;
|
||||
|
||||
return cloner.clonedReferenceElement instanceof cloneWindow.HTMLElement ||
|
||||
cloner.clonedReferenceElement instanceof ownerDocument.defaultView.HTMLElement ||
|
||||
cloner.clonedReferenceElement instanceof HTMLElement
|
||||
? Promise.resolve([
|
||||
cloneIframeContainer,
|
||||
cloner.clonedReferenceElement,
|
||||
cloner.resourceLoader
|
||||
])
|
||||
? typeof onclone === 'function'
|
||||
? Promise.resolve().then(() => onclone(documentClone)).then(() => result)
|
||||
: result
|
||||
: Promise.reject(
|
||||
__DEV__
|
||||
? `Error finding the ${referenceElement.nodeName} in the cloned document`
|
||||
|
@ -17,6 +17,7 @@ export type Options = {
|
||||
ignoreElements?: HTMLElement => boolean,
|
||||
imageTimeout: number,
|
||||
logging: boolean,
|
||||
onclone?: Document => void,
|
||||
proxy: ?string,
|
||||
removeContainer: ?boolean,
|
||||
scale: number,
|
||||
|
Reference in New Issue
Block a user