summaryrefslogtreecommitdiff
path: root/usvg/src
diff options
context:
space:
mode:
authorRazrFalcon <razrfalcon@gmail.com>2019-01-02 15:36:40 +0200
committerRazrFalcon <razrfalcon@gmail.com>2019-01-02 15:36:40 +0200
commit9d8c608f7e2720861aeaf912f1b1f72e75151e67 (patch)
tree7cd68f74a2ee526768fcf1dcc85842507af3d212 /usvg/src
parent44800cf63e58318e71b4866f4b6ba45398b91f50 (diff)
(usvg) Fixed 'symbol' resolving.
Diffstat (limited to 'usvg/src')
-rw-r--r--usvg/src/preproc/resolve_use.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/usvg/src/preproc/resolve_use.rs b/usvg/src/preproc/resolve_use.rs
index e31e1c8..96672d7 100644
--- a/usvg/src/preproc/resolve_use.rs
+++ b/usvg/src/preproc/resolve_use.rs
@@ -175,6 +175,20 @@ fn resolve_symbol(
// If 'clipPath' was created we have to set the original transform
// to the group that contains 'clip-path' attribute.
g_node.set_attribute((AId::Transform, orig_ts));
+
+ // Swap ID's.
+ g_node.set_id(use_node.id().as_str());
+ use_node.set_id(String::new());
+
+ // Relink the node.
+ for mut node in doc.root().descendants().filter(|n| n.is_tag_name(EId::Use)) {
+ let av = node.attributes().get_value(AId::Href).cloned();
+ if let Some(AValue::Link(link)) = av {
+ if link == *use_node {
+ node.set_attribute((AId::Href, g_node.clone()));
+ }
+ }
+ }
} else {
// Set the original transform back to the 'use' itself.
use_node.prepend_transform(orig_ts);