From 7309b97b923895f31c8baa4a7bd58a11f38d9e7a Mon Sep 17 00:00:00 2001 From: Vladimir Date: Sat, 17 Mar 2018 10:40:00 +0300 Subject: [PATCH] Fix the HTMLElement attributes copying --- Sources/HTMLElement.m | 2 +- Tests/HTMLKitTests/HTMLNodesTests.m | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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