Refactor method to get a node’s ancestor chain into the utils class

This commit is contained in:
iska
2016-12-30 03:07:33 +01:00
parent 3898ae243c
commit 7506ed8cae
3 changed files with 13 additions and 9 deletions
+9
View File
@@ -21,3 +21,12 @@ extern HTMLNode * GetCommonAncestorContainer(HTMLNode *nodeA, HTMLNode *nodeB)
return nil;
}
extern NSArray<HTMLNode *> * GetAncestorNodes(HTMLNode *node)
{
NSMutableArray *ancestors = [NSMutableArray array];
for (HTMLNode *it = node; it; it = it.parentNode) {
[ancestors addObject:it];
}
return ancestors;
}