mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
fix: svg d path getting truncated on copy (#2589)
This commit is contained in:
parent
45efe54da8
commit
dd6d8856ec
@ -443,12 +443,17 @@ const iframeLoader = (iframe: HTMLIFrameElement): Promise<HTMLIFrameElement> =>
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ignoredStyleProperties = [
|
||||||
|
'all', // #2476
|
||||||
|
'd', // #2483
|
||||||
|
'content' // Safari shows pseudoelements if content is set
|
||||||
|
];
|
||||||
|
|
||||||
export const copyCSSStyles = <T extends HTMLElement | SVGElement>(style: CSSStyleDeclaration, target: T): T => {
|
export const copyCSSStyles = <T extends HTMLElement | SVGElement>(style: CSSStyleDeclaration, target: T): T => {
|
||||||
// Edge does not provide value for cssText
|
// Edge does not provide value for cssText
|
||||||
for (let i = style.length - 1; i >= 0; i--) {
|
for (let i = style.length - 1; i >= 0; i--) {
|
||||||
const property = style.item(i);
|
const property = style.item(i);
|
||||||
// Safari shows pseudoelements if content is set
|
if (ignoredStyleProperties.indexOf(property) === -1) {
|
||||||
if (property !== 'content' && property !== 'all') {
|
|
||||||
target.style.setProperty(property, style.getPropertyValue(property));
|
target.style.setProperty(property, style.getPropertyValue(property));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,5 +40,13 @@
|
|||||||
<text x="65" y="35" class="canvas">canvas</text>
|
<text x="65" y="35" class="canvas">canvas</text>
|
||||||
</svg>
|
</svg>
|
||||||
<img width="200" height="200" src="data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjMwNiIgaGVpZ2h0PSIyOTYiPjxkZWZzIGlkPSJkZWZzNCIgLz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTYyLjQ2OTk1L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N0cm9rZS1vcGFjaXR5OjE7c3Ryb2tlLWRhc2hhcnJheTpub25lIiAvPjwvZz48L3N2Zz4=" /></div>
|
||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width=50 height=20>
|
||||||
|
<g data-z-index="0.1" opacity="1" transform="translate(-974,-30) scale(1 1)">
|
||||||
|
<path fill="#7cb5ec" d="M 990 37.734399999999994 A 4 4 0 1 1 990.0039999993332 37.73439800000016 Z" opacity="1" stroke-width="0.00015790535835003006"></path>
|
||||||
|
<path fill="#7cb5ec" d="M 999 37.734399999999994 A 4 4 0 1 1 999.0039999993332 37.73439800000016 Z" opacity="1" stroke-width="0.00015790535835003006"></path>
|
||||||
|
<path fill="#7cb5ec" d="M 1009 37.734399999999994 A 4 4 0 1 1 1009.0039999993332 37.73439800000016 Z" opacity="1" stroke-width="0.00015790535835003006"></path>
|
||||||
|
<path fill="#7cb5ec" d="M 1019 37.734399999999994 A 4 4 0 1 1 1019.0039999993332 37.73439800000016 Z" opacity="1" stroke-width="0.00015790535835003006"></path>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user