diff --git a/src/dom/document-cloner.ts b/src/dom/document-cloner.ts index 9603ef2..d3e347c 100644 --- a/src/dom/document-cloner.ts +++ b/src/dom/document-cloner.ts @@ -5,6 +5,7 @@ import { isElementNode, isHTMLElementNode, isIFrameElement, + isImageElement, isScriptElement, isSelectElement, isStyleElement, @@ -128,7 +129,15 @@ export class DocumentCloner { return this.createStyleClone(node); } - return node.cloneNode(false) as HTMLElement; + const clone = node.cloneNode(false) as HTMLElement; + + // @ts-ignore + if (isImageElement(clone) && clone.loading === 'lazy') { + // @ts-ignore + clone.loading = 'eager'; + } + + return clone; } createStyleClone(node: HTMLStyleElement): HTMLStyleElement { diff --git a/src/index.ts b/src/index.ts index e6bc7a8..8331f84 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,7 +25,7 @@ const html2canvas = (element: HTMLElement, options: Partial = {}): Prom export default html2canvas; -if (typeof window !== "undefined") { +if (typeof window !== 'undefined') { CacheStorage.setContext(window); } diff --git a/tests/reftests/images/images.html b/tests/reftests/images/images.html index 25b7dea..7456448 100644 --- a/tests/reftests/images/images.html +++ b/tests/reftests/images/images.html @@ -7,6 +7,7 @@ +