tsayen / dom-to-image

Generates an image from a DOM node using HTML5 canvas
Other
10.28k stars 1.68k forks source link

Fix cloning SVGAnimatedString #250

Open eddydg opened 5 years ago

eddydg commented 5 years ago

className can also be an instance of SVGAnimatedString if the element is an SVGElement. It is better to get/set the className of an element using Element.getAttribute and Element.setAttribute if you are dealing with SVG elements.

https://developer.mozilla.org/en-US/docs/Web/API/Element/className#Notes

SVGElement's className is not a string and thus we currently set an invalid class (eg. [object SVGAnimatedString] udfqi3) when cloning this kind of elements. Also it cannot be reassigned directly as it is a read-only property.

Using the provided getAttribute/setAttribute solve those problems.

Should also fix this issue https://github.com/tsayen/dom-to-image/issues/247

AntonioRedondo commented 5 years ago

@tsayen is this gonna be ever merged? We have the same issue hindering us to use dom-to-mage. This pull request fixes the issue.

IDisposable commented 5 years ago

Released in https://github.com/1904labs/dom-to-image-more v2.8.0