From 01fadbb8286247e1367f711741139bb96d0efca0 Mon Sep 17 00:00:00 2001 From: ty0x2333 Date: Tue, 8 Mar 2022 05:05:10 +0800 Subject: [PATCH] SVGParser will parse the `class` attribute as Node Tag. --- Source/svg/SVGParser.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/svg/SVGParser.swift b/Source/svg/SVGParser.swift index 58bf22c6..3a9164df 100644 --- a/Source/svg/SVGParser.swift +++ b/Source/svg/SVGParser.swift @@ -897,8 +897,15 @@ open class SVGParser { } fileprivate func getTag(_ element: XMLHash.XMLElement) -> [String] { - let id = element.allAttributes["id"]?.text - return id.map { [$0] } ?? [] + var result: [String] = [] + if let id = element.allAttributes["id"]?.text { + result.append(id) + } + if let classes = element.allAttributes["class"]?.text.split(separator: " ").map({ String($0) }) { + result.append(contentsOf: classes) + } + + return Array(Set(result)) } fileprivate func getOpacity(_ styleParts: [String: String]) -> Double {