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..aa7fd901 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: BONColor.white])) + .byAdding(.extraAttributes([.foregroundColor: BONColor.black])) + + BONAssert(attributes: style.attributes, key: .backgroundColor, value: BONColor.white) + BONAssert(attributes: style.attributes, key: .foregroundColor, value: BONColor.black) + } + } private extension StringStyleTests {