Add HTML Node deep clone implementation

This commit is contained in:
iska
2017-01-08 09:31:37 +01:00
parent 0ac49f2a0f
commit e48ccf42ca
2 changed files with 23 additions and 0 deletions
+15
View File
@@ -668,6 +668,21 @@ NS_INLINE void CheckInvalidCombination(HTMLNode *parent, HTMLNode *node, NSStrin
#endif
#pragma mark - Clone
- (instancetype)cloneNodeDeep:(BOOL)deep
{
HTMLNode *copy = [self copy];
if (deep) {
for (HTMLNode *child in self.childNodes) {
[copy appendNode:[child cloneNodeDeep:YES]];
}
}
return copy;
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone
+8
View File
@@ -186,6 +186,14 @@ typedef NS_OPTIONS(unsigned short, HTMLDocumentPosition)
*/
- (BOOL)isEmpty;
/**
Clones this node.
@param deep If `YES` then also clones child nodes. Otherwise a shallow clone is returned, which behaves the same as `copy`.
@return A clone of this node.
*/
- (instancetype)cloneNodeDeep:(BOOL)deep;
/**
Returns the child node at a given index.