mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
fix: logger unique names (#2575)
This commit is contained in:
parent
99b8182991
commit
171585491d
@ -29,7 +29,12 @@ if (typeof window !== 'undefined') {
|
|||||||
CacheStorage.setContext(window);
|
CacheStorage.setContext(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let instanceCount = 1;
|
||||||
|
|
||||||
const renderElement = async (element: HTMLElement, opts: Partial<Options>): Promise<HTMLCanvasElement> => {
|
const renderElement = async (element: HTMLElement, opts: Partial<Options>): Promise<HTMLCanvasElement> => {
|
||||||
|
if (typeof element !== 'object') {
|
||||||
|
return Promise.reject('Invalid element provided as first argument');
|
||||||
|
}
|
||||||
const ownerDocument = element.ownerDocument;
|
const ownerDocument = element.ownerDocument;
|
||||||
|
|
||||||
if (!ownerDocument) {
|
if (!ownerDocument) {
|
||||||
@ -42,7 +47,7 @@ const renderElement = async (element: HTMLElement, opts: Partial<Options>): Prom
|
|||||||
throw new Error(`Document is not attached to a Window`);
|
throw new Error(`Document is not attached to a Window`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const instanceName = (Math.round(Math.random() * 1000) + Date.now()).toString(16);
|
const instanceName = `#${instanceCount++}`;
|
||||||
|
|
||||||
const {width, height, left, top} =
|
const {width, height, left, top} =
|
||||||
isBodyElement(element) || isHTMLElement(element) ? parseDocumentSize(ownerDocument) : parseBounds(element);
|
isBodyElement(element) || isHTMLElement(element) ? parseDocumentSize(ownerDocument) : parseBounds(element);
|
||||||
|
Loading…
Reference in New Issue
Block a user