mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Prepare for PR to html2canvas repo
This commit is contained in:
parent
313bd4e4c6
commit
3d559c79df
@ -22,6 +22,5 @@
|
|||||||
"@typescript-eslint/no-unused-vars": "off",
|
"@typescript-eslint/no-unused-vars": "off",
|
||||||
"@typescript-eslint/class-name-casing": "off",
|
"@typescript-eslint/class-name-casing": "off",
|
||||||
"prettier/prettier": "error"
|
"prettier/prettier": "error"
|
||||||
},
|
}
|
||||||
"root": true
|
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,6 @@ export interface CloneOptions {
|
|||||||
ignoreElements?: (element: Element) => boolean;
|
ignoreElements?: (element: Element) => boolean;
|
||||||
onclone?: (document: Document, element: HTMLElement) => void;
|
onclone?: (document: Document, element: HTMLElement) => void;
|
||||||
allowTaint?: boolean;
|
allowTaint?: boolean;
|
||||||
hide_selector?: string;
|
|
||||||
masked_class?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WindowOptions {
|
export interface WindowOptions {
|
||||||
@ -276,21 +274,15 @@ export class DocumentCloner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
appendChildNode(clone: HTMLElement | SVGElement, child: Node, copyStyles: boolean): void {
|
appendChildNode(clone: HTMLElement | SVGElement, child: Node, copyStyles: boolean): void {
|
||||||
const {ignoreElements, hide_selector, masked_class = ''} = this.options;
|
|
||||||
if (
|
if (
|
||||||
!isElementNode(child) ||
|
!isElementNode(child) ||
|
||||||
(!isScriptElement(child) &&
|
(!isScriptElement(child) &&
|
||||||
!child.hasAttribute(IGNORE_ATTRIBUTE) &&
|
!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 (!this.options.copyStyles || !isElementNode(child) || !isStyleElement(child)) {
|
||||||
if (hide_selector && isElementNode(clonedNode) && clonedNode.matches(hide_selector)) {
|
clone.appendChild(this.cloneNode(child, copyStyles));
|
||||||
if (isImageElement(clonedNode)) {
|
|
||||||
clonedNode.style.visibility = 'hidden';
|
|
||||||
}
|
}
|
||||||
clonedNode.classList.add(masked_class);
|
|
||||||
}
|
|
||||||
clone.appendChild(clonedNode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,9 +78,7 @@ const renderElement = async (element: HTMLElement, opts: Partial<Options>): Prom
|
|||||||
onclone: opts.onclone,
|
onclone: opts.onclone,
|
||||||
ignoreElements: opts.ignoreElements,
|
ignoreElements: opts.ignoreElements,
|
||||||
inlineImages: foreignObjectRendering,
|
inlineImages: foreignObjectRendering,
|
||||||
copyStyles: foreignObjectRendering,
|
copyStyles: foreignObjectRendering
|
||||||
hide_selector: opts.hide_selector,
|
|
||||||
masked_class: opts.masked_class
|
|
||||||
};
|
};
|
||||||
|
|
||||||
context.logger.debug(
|
context.logger.debug(
|
||||||
|
Loading…
Reference in New Issue
Block a user