From 3d559c79dfafa51ca3352236d79e5f5fc5aa582e Mon Sep 17 00:00:00 2001 From: Yuri Papouski Date: Fri, 9 Sep 2022 13:56:49 +0000 Subject: [PATCH] Prepare for PR to html2canvas repo --- .eslintrc | 3 +-- src/dom/document-cloner.ts | 14 +++----------- src/index.ts | 4 +--- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.eslintrc b/.eslintrc index 9b0a890..c5efba2 100644 --- a/.eslintrc +++ b/.eslintrc @@ -22,6 +22,5 @@ "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/class-name-casing": "off", "prettier/prettier": "error" - }, - "root": true + } } diff --git a/src/dom/document-cloner.ts b/src/dom/document-cloner.ts index 409dd7f..08faa29 100644 --- a/src/dom/document-cloner.ts +++ b/src/dom/document-cloner.ts @@ -29,8 +29,6 @@ export interface CloneOptions { ignoreElements?: (element: Element) => boolean; onclone?: (document: Document, element: HTMLElement) => void; allowTaint?: boolean; - hide_selector?: string; - masked_class?: string; } export interface WindowOptions { @@ -276,21 +274,15 @@ export class DocumentCloner { } appendChildNode(clone: HTMLElement | SVGElement, child: Node, copyStyles: boolean): void { - const {ignoreElements, hide_selector, masked_class = ''} = this.options; if ( !isElementNode(child) || (!isScriptElement(child) && !child.hasAttribute(IGNORE_ATTRIBUTE) && - (typeof ignoreElements !== 'function' || !ignoreElements(child))) + (typeof this.options.ignoreElements !== 'function' || !this.options.ignoreElements(child))) ) { - const clonedNode = this.cloneNode(child, copyStyles); - if (hide_selector && isElementNode(clonedNode) && clonedNode.matches(hide_selector)) { - if (isImageElement(clonedNode)) { - clonedNode.style.visibility = 'hidden'; - } - clonedNode.classList.add(masked_class); + if (!this.options.copyStyles || !isElementNode(child) || !isStyleElement(child)) { + clone.appendChild(this.cloneNode(child, copyStyles)); } - clone.appendChild(clonedNode); } } diff --git a/src/index.ts b/src/index.ts index bbbc4f2..348b050 100644 --- a/src/index.ts +++ b/src/index.ts @@ -78,9 +78,7 @@ const renderElement = async (element: HTMLElement, opts: Partial): Prom onclone: opts.onclone, ignoreElements: opts.ignoreElements, inlineImages: foreignObjectRendering, - copyStyles: foreignObjectRendering, - hide_selector: opts.hide_selector, - masked_class: opts.masked_class + copyStyles: foreignObjectRendering }; context.logger.debug(