mathandy / svgpathtools

A collection of tools for manipulating and analyzing SVG Path objects and Bezier curves.
MIT License
557 stars 142 forks source link

Document does not add path to empty group #169

Closed chanicpanic closed 2 years ago

chanicpanic commented 2 years ago

When the passed group element has no children, Document.add_path incorrectly adds the path to the root element.

Example:

doc = Document()
empty = doc.add_group(group_attribs={"id": "empty"})
doc.add_path("M 0,0 L 1,1", group=empty)
print(doc)

Output:

<svg xmlns:svg="http://www.w3.org/2000/svg"><svg:g id="empty" /><path d="M 0,0 L 1,1" /></svg>

Expected Output:

<svg xmlns:svg="http://www.w3.org/2000/svg"><svg:g id="empty"><path d="M 0,0 L 1,1" /></svg:g></svg>