From 42faf6f8c6461f5f77c549db1dc8d7abcb75c934 Mon Sep 17 00:00:00 2001 From: mzh3511 <287972920@qq.com> Date: Wed, 10 May 2023 20:23:36 +0800 Subject: [PATCH] Add copying _styles in DeepCopy (#1053) * DeepCopy missed coping _styles * needed for svg elements with styles which include clip-path --- Source/SvgElement.cs | 4 ++++ doc/ReleaseNotes.md | 1 + 2 files changed, 5 insertions(+) diff --git a/Source/SvgElement.cs b/Source/SvgElement.cs index 8eba05ff5..3d9a56b9d 100644 --- a/Source/SvgElement.cs +++ b/Source/SvgElement.cs @@ -1044,6 +1044,10 @@ ISvgNode ISvgNode.DeepCopy() foreach (var node in Nodes) newObj.Nodes.Add(node.DeepCopy()); + foreach (var style in _styles) + foreach (var pair in style.Value) + newObj.AddStyle(style.Key, pair.Value, pair.Key); + return newObj; } diff --git a/doc/ReleaseNotes.md b/doc/ReleaseNotes.md index d07044dc5..c9dc1f571 100644 --- a/doc/ReleaseNotes.md +++ b/doc/ReleaseNotes.md @@ -9,6 +9,7 @@ The release versions are NuGet releases. ### Fixes * fixed build error in C# 11 (see [PR #1030](https://github.com/svg-net/SVG/pull/1030)) * fixed out of memory exception on SVGs with gradients (see [PR #1038] (https://github.com/svg-net/SVG/pull/1038)) +* fixed missing styles when `DeepCopy` the `SvgElement` (see [PR #1053] (https://github.com/svg-net/SVG/pull/1053)) ## [Version 3.4.4](https://www.nuget.org/packages/Svg/3.4.4) (2022-10-29)