mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Fix recursion for safari 10 on pseudoelements
This commit is contained in:
parent
c2c91a50b8
commit
769d74351c
@ -4,8 +4,7 @@
|
|||||||
import type {Font} from './parsing/font';
|
import type {Font} from './parsing/font';
|
||||||
|
|
||||||
const SAMPLE_TEXT = 'Hidden Text';
|
const SAMPLE_TEXT = 'Hidden Text';
|
||||||
const SMALL_IMAGE =
|
import {SMALL_IMAGE} from './Util';
|
||||||
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
|
||||||
|
|
||||||
export class FontMetrics {
|
export class FontMetrics {
|
||||||
_data: {};
|
_data: {};
|
||||||
|
@ -46,6 +46,10 @@ const parseNodeTree = (
|
|||||||
imageLoader: ImageLoader,
|
imageLoader: ImageLoader,
|
||||||
index: number
|
index: number
|
||||||
): void => {
|
): void => {
|
||||||
|
if (__DEV__ && index > 50000) {
|
||||||
|
throw new Error(`Recursion error while parsing node tree`);
|
||||||
|
}
|
||||||
|
|
||||||
for (let childNode = node.firstChild, nextNode; childNode; childNode = nextNode) {
|
for (let childNode = node.firstChild, nextNode; childNode; childNode = nextNode) {
|
||||||
nextNode = childNode.nextSibling;
|
nextNode = childNode.nextSibling;
|
||||||
const defaultView = childNode.ownerDocument.defaultView;
|
const defaultView = childNode.ownerDocument.defaultView;
|
||||||
|
14
src/Util.js
14
src/Util.js
@ -4,13 +4,15 @@
|
|||||||
export const contains = (bit: number, value: number): boolean => (bit & value) !== 0;
|
export const contains = (bit: number, value: number): boolean => (bit & value) !== 0;
|
||||||
|
|
||||||
export const copyCSSStyles = (style: CSSStyleDeclaration, target: HTMLElement): void => {
|
export const copyCSSStyles = (style: CSSStyleDeclaration, target: HTMLElement): void => {
|
||||||
if (style.cssText) {
|
// Edge does not provide value for cssText
|
||||||
target.style.cssText = style.cssText;
|
for (let i = style.length - 1; i >= 0; i--) {
|
||||||
} else {
|
const property = style.item(i);
|
||||||
// Edge does not provide value for cssText
|
// Safari shows pseudoelements if content is set
|
||||||
for (let i = style.length - 1; i >= 0; i--) {
|
if (property !== 'content') {
|
||||||
const property = style.item(i);
|
|
||||||
target.style.setProperty(property, style.getPropertyValue(property));
|
target.style.setProperty(property, style.getPropertyValue(property));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const SMALL_IMAGE =
|
||||||
|
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user