Skip to content

Commit

Permalink
fix: logger unique names (#2575)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasvh authored Jul 13, 2021
1 parent 99b8182 commit 1715854
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ if (typeof window !== 'undefined') {
CacheStorage.setContext(window);
}

let instanceCount = 1;

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;

if (!ownerDocument) {
Expand All @@ -42,7 +47,7 @@ const renderElement = async (element: HTMLElement, opts: Partial<Options>): Prom
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} =
isBodyElement(element) || isHTMLElement(element) ? parseDocumentSize(ownerDocument) : parseBounds(element);
Expand Down

0 comments on commit 1715854

Please sign in to comment.