Add Node properties for previous and next sibling elements

This commit is contained in:
iska
2015-11-27 01:10:07 +01:00
parent 09991a149f
commit c09adc2f96
2 changed files with 22 additions and 0 deletions
+4
View File
@@ -62,6 +62,10 @@ typedef NS_ENUM(unsigned short, HTMLDocumentPosition)
@property (nonatomic, strong, readonly) HTMLNode *nextSibling;
@property (nonatomic, strong, readonly) HTMLElement *previousSiblingElement;
@property (nonatomic, strong, readonly) HTMLElement *nextSiblingElement;
@property (nonatomic, copy) NSString *textContent;
@property (nonatomic, strong, readonly) NSString *outerHTML;
+18
View File
@@ -99,6 +99,24 @@
return [_parentNode childNodeAtIndex:index + 1];
}
- (HTMLElement *)previousSiblingElement
{
HTMLNode *node = self.previousSibling;
while (node && node.nodeType != HTMLNodeElement) {
node = node.previousSibling;
}
return node.asElement;
}
- (HTMLElement *)nextSiblingElement
{
HTMLNode *node = self.previousSibling;
while (node && node.nodeType != HTMLNodeElement) {
node = node.nextSibling;
}
return node.asElement;
}
- (NSString *)textContent
{
return nil;