From d6e261b9ff9fc2289974826ceb0c00b16eedf73d Mon Sep 17 00:00:00 2001 From: tebjan Date: Sat, 29 Mar 2014 01:46:37 +0000 Subject: [PATCH] remove uses depth first recursion for children --- Source/SvgElementCollection.cs | 2 +- Source/SvgExtentions.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/SvgElementCollection.cs b/Source/SvgElementCollection.cs index a13d5f4..7b5939a 100644 --- a/Source/SvgElementCollection.cs +++ b/Source/SvgElementCollection.cs @@ -156,7 +156,7 @@ namespace Svg if (this._owner.OwnerDocument != null) { - item.ApplyRecursive(this._owner.OwnerDocument.IdManager.Remove); + item.ApplyRecursiveDepthFirst(this._owner.OwnerDocument.IdManager.Remove); } } } diff --git a/Source/SvgExtentions.cs b/Source/SvgExtentions.cs index dd95152..9a93277 100644 --- a/Source/SvgExtentions.cs +++ b/Source/SvgExtentions.cs @@ -81,5 +81,18 @@ namespace Svg } } } + + public static void ApplyRecursiveDepthFirst(this SvgElement elem, Action action) + { + if(!(elem is SvgDocument)) //don't apply action to subtree of documents + { + foreach (var element in elem.Children) + { + element.ApplyRecursiveDepthFirst(action); + } + } + + action(elem); + } } } -- GitLab