mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
feat: allow access to reference element in onclone (#2584)
This commit is contained in:
parent
92fa448913
commit
58b4591174
@ -24,7 +24,7 @@ import {getQuote} from '../css/property-descriptors/quotes';
|
|||||||
export interface CloneOptions {
|
export interface CloneOptions {
|
||||||
id: string;
|
id: string;
|
||||||
ignoreElements?: (element: Element) => boolean;
|
ignoreElements?: (element: Element) => boolean;
|
||||||
onclone?: (document: Document) => void;
|
onclone?: (document: Document, element: HTMLElement) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CloneConfigurations = CloneOptions & {
|
export type CloneConfigurations = CloneOptions & {
|
||||||
@ -89,7 +89,9 @@ export class DocumentCloner {
|
|||||||
|
|
||||||
const onclone = this.options.onclone;
|
const onclone = this.options.onclone;
|
||||||
|
|
||||||
if (typeof this.clonedReferenceElement === 'undefined') {
|
const referenceElement = this.clonedReferenceElement;
|
||||||
|
|
||||||
|
if (typeof referenceElement === 'undefined') {
|
||||||
return Promise.reject(`Error finding the ${this.referenceElement.nodeName} in the cloned document`);
|
return Promise.reject(`Error finding the ${this.referenceElement.nodeName} in the cloned document`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +105,7 @@ export class DocumentCloner {
|
|||||||
|
|
||||||
if (typeof onclone === 'function') {
|
if (typeof onclone === 'function') {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(() => onclone(documentClone))
|
.then(() => onclone(documentClone, referenceElement))
|
||||||
.then(() => iframe);
|
.then(() => iframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user