I've done some work in trying to implement this. There are some complications due to some security issues of downloading embedded objects (I believe canvases which are in svgs may not be automatically inserted), and text/DOM and particularly <foreignObjects> elements may give issues.
I've done some work in trying to implement this. There are some complications due to some security issues of downloading embedded objects (I believe canvases which are in svgs may not be automatically inserted), and text/DOM and particularly
<foreignObjects>
elements may give issues.see: https://observablehq.com/@mbostock/saving-svg and : https://observablehq.com/@mootari/embed-canvas-into-svg and : https://stackoverflow.com/questions/39148582/javascript-todataurl-throwing-security-error-tainted-canvases-may-not-be-ex/39150005