UNPKG

@yookue/ts-lang-utils

Version:

Common lang utilities for typescript

15 lines 460 B
import { downloadUrlByElement } from "./downloadUrlByElement"; export function downloadSvgElement(element, fileName) { if (!element || !fileName) { return; } var target = element.querySelector('svg'); if (target) { var data = new XMLSerializer().serializeToString(target); var blob = new Blob([data], { type: 'image/svg+xml;charset=utf-8' }); var url = URL.createObjectURL(blob); downloadUrlByElement(url, fileName); } }