@@ -28,18 +28,26 @@ function xmlnode(tag, attrs, children=nothing)
28
28
end
29
29
function xml_addchildren! (svgdoc:: Node , children)
30
30
children isa Pair && (children = (children,))
31
+ rt = svgdoc[end ]
31
32
for (e, attrs) in children
32
- pushfirst! (svgdoc[end ]. children, xmlnode (e, attrs))
33
+ c = xmlnode (e, attrs)
34
+ if isempty (XML. children (rt))
35
+ rt = Node (nodetype (rt), tag (rt), attributes (rt), value (rt), c)
36
+ else
37
+ pushfirst! (rt. children, c)
38
+ end
33
39
end
40
+ svgdoc[end ] = rt
34
41
svgdoc
35
42
end
36
43
37
44
function xml_wrapchildren! (svgdoc:: Node , wrappers)
38
45
wrappers isa Pair && (wrappers = (wrappers,))
39
46
for (e, attrs) in wrappers
40
- we = xmlnode (e, attrs, copy (children (svgdoc[end ])))
41
- empty! (svgdoc[end ]. children)
42
- push! (svgdoc[end ]. children, we)
47
+ lastnode = svgdoc[end ]
48
+ we = xmlnode (e, attrs, children (lastnode))
49
+ we = Node (nodetype (lastnode), tag (lastnode), attributes (lastnode), value (lastnode), we)
50
+ svgdoc[end ] = we
43
51
end
44
52
svgdoc
45
53
end
@@ -50,7 +58,7 @@ function xml_stack!(svgs::AbstractVector{Node})
50
58
for svg in rest
51
59
for c in children (svg[end ])
52
60
if isempty (children (rt))
53
- rt = Node (XML . nodetype (rt), tag (rt), XML . attributes (rt), value (rt), c)
61
+ rt = Node (nodetype (rt), tag (rt), attributes (rt), value (rt), c)
54
62
else
55
63
push! (rt, c)
56
64
end
0 commit comments