Skip to content

Commit 4200c3f

Browse files
committed
Support color: transparent
1 parent 6b176b5 commit 4200c3f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

SwiftDraw/Parser.XML.Color.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ extension XMLParser {
5555
}
5656

5757
private func parseColorNone(data: String) -> DOM.Color? {
58-
if data.trimmingCharacters(in: .whitespaces) == "none" {
58+
let trimmed = data.trimmingCharacters(in: .whitespaces)
59+
if trimmed == "none" || trimmed == "transparent" {
5960
return DOM.Color.none // .none resolves to Optional.none
6061
}
6162
return nil

SwiftDrawTests/Parser.XML.ColorTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ final class ParserColorTests: XCTestCase {
4040
XCTAssertEqual(try XMLParser().parseColor("\t none \t"), .none)
4141
}
4242

43+
func testColorTransparent() {
44+
XCTAssertEqual(try XMLParser().parseColor("transparent"), .none)
45+
XCTAssertEqual(try XMLParser().parseColor(" transparent"), .none)
46+
XCTAssertEqual(try XMLParser().parseColor("\t transparent \t"), .none)
47+
}
48+
4349
func testColorCurrent() {
4450
XCTAssertEqual(try XMLParser().parseColor("currentColor"), .currentColor)
4551
XCTAssertEqual(try XMLParser().parseColor(" currentColor"), .currentColor)

0 commit comments

Comments
 (0)