Add HTML Comment node

https://dom.spec.whatwg.org/#interface-comment
This commit is contained in:
iska
2015-02-26 20:08:06 +01:00
parent 5e9846b8ea
commit c45adc581b
4 changed files with 70 additions and 2 deletions
+17
View File
@@ -0,0 +1,17 @@
//
// HTMLComment.h
// HTMLKit
//
// Created by Iska on 25/02/15.
// Copyright (c) 2015 BrainCookie. All rights reserved.
//
#import "HTMLNode.h"
@interface HTMLComment : HTMLNode
@property (nonatomic, copy) NSString *data;
- (instancetype)initWithData:(NSString *)data;
@end
+41
View File
@@ -0,0 +1,41 @@
//
// HTMLComment.m
// HTMLKit
//
// Created by Iska on 25/02/15.
// Copyright (c) 2015 BrainCookie. All rights reserved.
//
#import "HTMLComment.h"
@implementation HTMLComment
- (instancetype)initWithData:(NSString *)data
{
self = [super initWithName:@"#comment" type:HTMLCommentNode];
if (self) {
self.data = data ?: @"";
}
return self;
}
- (NSString *)textContent
{
return self.data;
}
- (void)setTextContent:(NSString *)textContent
{
self.data = textContent ?: @"";
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone
{
HTMLComment *copy = [super copyWithZone:zone];
copy.data = self.data;
return copy;
}
@end
+2 -2
View File
@@ -51,10 +51,10 @@ typedef NS_ENUM(short, HTMLNodeType)
@property (nonatomic, strong, readonly) HTMLNode *nextSibling;
@property (nonatomic, copy) NSString *value;
@property (nonatomic, copy) NSString *textContent;
- (instancetype)initWithName:(NSString *)name type:(HTMLNodeType)type;
- (BOOL)hasChildNodes;
- (HTMLNode *)childNodeAtIndex:(NSUInteger)index;