yWorks / svg2pdf.js

A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
MIT License
667 stars 104 forks source link

Fill and stroke attributes are not inherited from parent element #27

Closed TorsteinHonsi closed 7 years ago

TorsteinHonsi commented 7 years ago

Live demo: https://jsfiddle.net/highcharts/7r9r26vL/1/

Expected attributes on the parent group to cascade down to children.

yGuy commented 7 years ago

Spec: https://www.w3.org/TR/SVG/painting.html#InheritanceOfPaintingProperties

yGuy commented 7 years ago

We should improve the code in https://github.com/yWorks/svg2pdf.js/blob/master/src/svg2pdf.js#L137 to walk upwards in the node element hierarchy to find the value if none is specified locally. This should only be done for inheritable attributes, though.

HackbrettXXX commented 7 years ago

I decided to use a "top down"/state approach where all inheritable attributes are passed to child nodes and overwritten when the child nodes specify the respective attributes themselves. Seems to be clearer to me and attributes don't have to be read several times.

TorsteinHonsi commented 7 years ago

Thanks so much! Will you build a new release or will you add more fixes first?

yGuy commented 7 years ago

We're currently doing a round of bug fixing and will release a new build sometime in the next two weeks.