From eefdc7e21bb7e446e3d45ab44d1f868581e618f8 Mon Sep 17 00:00:00 2001 From: Dongkyu Kim Date: Fri, 9 Jun 2023 20:52:13 +0900 Subject: [PATCH 1/2] Use `add(extraAttributes:)` for .extraAttributes(_:)` in `update(part:)` --- Sources/StringStyle+Part.swift | 2 +- Tests/AttributedStringStyleTests.swift | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/StringStyle+Part.swift b/Sources/StringStyle+Part.swift index 776ecce4..a2845d51 100644 --- a/Sources/StringStyle+Part.swift +++ b/Sources/StringStyle+Part.swift @@ -165,7 +165,7 @@ extension StringStyle { mutating func update(part stylePart: Part) { switch stylePart { case let .extraAttributes(attributes): - self.extraAttributes = attributes + self.add(extraAttributes: attributes) case let .font(font): self.font = font case let .link(link): diff --git a/Tests/AttributedStringStyleTests.swift b/Tests/AttributedStringStyleTests.swift index 8e43bba8..ce277d96 100644 --- a/Tests/AttributedStringStyleTests.swift +++ b/Tests/AttributedStringStyleTests.swift @@ -829,6 +829,15 @@ class StringStyleTests: XCTestCase { BONAssert(attributes: childAttributes, key: .foregroundColor, value: BONColor.black) } + func testOverridingExtraAttributesPart() { + let style = StringStyle() + .byAdding(.extraAttributes([.backgroundColor: UIColor.white])) + .byAdding(.extraAttributes([.foregroundColor: UIColor.black])) + + BONAssert(attributes: style.attributes, key: .backgroundColor, value: UIColor.white) + BONAssert(attributes: style.attributes, key: .foregroundColor, value: UIColor.black) + } + } private extension StringStyleTests { From 90e216b96666671c969efa18d727492acd7cf101 Mon Sep 17 00:00:00 2001 From: "Dongkyu Kim (Max)" Date: Fri, 9 Jun 2023 22:45:43 +0900 Subject: [PATCH 2/2] Swap `UIColor` for `BONColor` --- Tests/AttributedStringStyleTests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/AttributedStringStyleTests.swift b/Tests/AttributedStringStyleTests.swift index ce277d96..aa7fd901 100644 --- a/Tests/AttributedStringStyleTests.swift +++ b/Tests/AttributedStringStyleTests.swift @@ -831,11 +831,11 @@ class StringStyleTests: XCTestCase { func testOverridingExtraAttributesPart() { let style = StringStyle() - .byAdding(.extraAttributes([.backgroundColor: UIColor.white])) - .byAdding(.extraAttributes([.foregroundColor: UIColor.black])) + .byAdding(.extraAttributes([.backgroundColor: BONColor.white])) + .byAdding(.extraAttributes([.foregroundColor: BONColor.black])) - BONAssert(attributes: style.attributes, key: .backgroundColor, value: UIColor.white) - BONAssert(attributes: style.attributes, key: .foregroundColor, value: UIColor.black) + BONAssert(attributes: style.attributes, key: .backgroundColor, value: BONColor.white) + BONAssert(attributes: style.attributes, key: .foregroundColor, value: BONColor.black) } }