Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Commit

Permalink
Fixed attributes resolving during the defs regrouping.
Browse files Browse the repository at this point in the history
Closes #138
  • Loading branch information
RazrFalcon committed Apr 7, 2018
1 parent c064f88 commit 5927867
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http:https://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http:https://semver.org/).

## [Unreleased]
### Fixed
- Attributes resolving during the `defs` regrouping.

## [0.9.4] - 2018-03-22
### Fixed
Expand Down
24 changes: 21 additions & 3 deletions src/task/group_defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ fn resolve_attrs(node: &Node) {
| EId::Mask
| EId::Pattern
| EId::Symbol => {
let mut parent = node.clone();
while let Some(p) = parent.parent() {
let mut parent = Some(node.clone());
while let Some(p) = parent {
let attrs = p.attributes();
for (aid, attr) in attrs.iter_svg().filter(|&(_, a)| a.is_inheritable()) {
for mut child in node.children() {
Expand All @@ -118,7 +118,7 @@ fn resolve_attrs(node: &Node) {
}
}

parent = p.clone();
parent = p.parent();
}
}
_ => {}
Expand Down Expand Up @@ -318,6 +318,24 @@ mod tests {
</defs>
<g fill='url(#lg1)'/>
</svg>
");

test!(move_attrs_3,
"<svg>
<g fill='none'>
<mask fill='#ff0000'>
<path/>
</mask>
</g>
</svg>",
"<svg>
<defs>
<mask fill='#ff0000'>
<path fill='#ff0000'/>
</mask>
</defs>
<g fill='none'/>
</svg>
");

}

0 comments on commit 5927867

Please sign in to comment.