mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
fix: responsive svg images (#2583)
This commit is contained in:

committed by
GitHub

parent
1acdc827a4
commit
92fa448913
@ -1,5 +1,6 @@
|
||||
import {ElementContainer} from '../element-container';
|
||||
import {CacheStorage} from '../../core/cache-storage';
|
||||
import {parseBounds} from '../../css/layout/bounds';
|
||||
|
||||
export class SVGElementContainer extends ElementContainer {
|
||||
svg: string;
|
||||
@ -9,6 +10,10 @@ export class SVGElementContainer extends ElementContainer {
|
||||
constructor(img: SVGSVGElement) {
|
||||
super(img);
|
||||
const s = new XMLSerializer();
|
||||
const bounds = parseBounds(img);
|
||||
img.setAttribute('width', `${bounds.width}px`);
|
||||
img.setAttribute('height', `${bounds.height}px`);
|
||||
|
||||
this.svg = `data:image/svg+xml,${encodeURIComponent(s.serializeToString(img))}`;
|
||||
this.intrinsicWidth = img.width.baseVal.value;
|
||||
this.intrinsicHeight = img.height.baseVal.value;
|
||||
|
Reference in New Issue
Block a user