diff --git a/Sources/HTMLElement.m b/Sources/HTMLElement.m index 7904e33..2686818 100644 --- a/Sources/HTMLElement.m +++ b/Sources/HTMLElement.m @@ -144,7 +144,7 @@ { HTMLElement *copy = [super copyWithZone:zone]; copy->_tagName = [_tagName copy]; - copy->_attributes = [_attributes copy]; + copy->_attributes = [_attributes mutableCopy]; copy->_htmlNamespace = _htmlNamespace; return copy; } diff --git a/Tests/HTMLKitTests/HTMLNodesTests.m b/Tests/HTMLKitTests/HTMLNodesTests.m index 8e994dd..7b627cf 100644 --- a/Tests/HTMLKitTests/HTMLNodesTests.m +++ b/Tests/HTMLKitTests/HTMLNodesTests.m @@ -512,4 +512,15 @@ XCTAssertTrue([image compareDocumentPositionWithNode:outerDiv] == (HTMLDocumentPositionContainedBy | HTMLDocumentPositionFollowing)); } +- (void)testDeepCloneElement { + HTMLElement *element = [HTMLElement new]; + element.elementId = @"originalId"; + + HTMLElement *clone = [element cloneNodeDeep:YES]; + NSString *cloneId = @"cloneId"; + clone.elementId = cloneId; + + XCTAssertTrue([clone.elementId isEqualToString:cloneId]); +} + @end