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
a101b52685
commit
ea080e0f5d
@ -4,8 +4,7 @@
|
||||
import type {Font} from './parsing/font';
|
||||
|
||||
const SAMPLE_TEXT = 'Hidden Text';
|
||||
const SMALL_IMAGE =
|
||||
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
import {SMALL_IMAGE} from './Util';
|
||||
|
||||
export class FontMetrics {
|
||||
_data: {};
|
||||
|
@ -46,6 +46,10 @@ const parseNodeTree = (
|
||||
imageLoader: ImageLoader,
|
||||
index: number
|
||||
): void => {
|
||||
if (__DEV__ && index > 50000) {
|
||||
throw new Error(`Recursion error while parsing node tree`);
|
||||
}
|
||||
|
||||
for (let childNode = node.firstChild, nextNode; childNode; childNode = nextNode) {
|
||||
nextNode = childNode.nextSibling;
|
||||
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 copyCSSStyles = (style: CSSStyleDeclaration, target: HTMLElement): void => {
|
||||
if (style.cssText) {
|
||||
target.style.cssText = style.cssText;
|
||||
} else {
|
||||
// Edge does not provide value for cssText
|
||||
for (let i = style.length - 1; i >= 0; i--) {
|
||||
const property = style.item(i);
|
||||
// Edge does not provide value for cssText
|
||||
for (let i = style.length - 1; i >= 0; i--) {
|
||||
const property = style.item(i);
|
||||
// Safari shows pseudoelements if content is set
|
||||
if (property !== 'content') {
|
||||
target.style.setProperty(property, style.getPropertyValue(property));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const SMALL_IMAGE =
|
||||
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
|
Loading…
Reference in New Issue
Block a user