Fix initial values for HTML Tokens and handle nil-parameter
This commit is contained in:
@@ -20,13 +20,16 @@
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_characters = [[NSMutableString alloc] initWithString:string];
|
||||
_characters = [string mutableCopy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)appendString:(NSString *)string
|
||||
{
|
||||
if (_characters == nil) {
|
||||
_characters = [NSMutableString new];
|
||||
}
|
||||
[_characters appendString:string];
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,16 @@
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.type = HTMLTokenTypeComment;
|
||||
_data = [[NSMutableString alloc] initWithString:data];
|
||||
_data = [data mutableCopy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)appendStringToData:(NSString *)string
|
||||
{
|
||||
if (_data == nil) {
|
||||
_data = [NSMutableString new];
|
||||
}
|
||||
[_data appendString:string];
|
||||
}
|
||||
|
||||
|
||||
@@ -23,13 +23,16 @@
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.type = HTMLTokenTypeDoctype;
|
||||
_name = [[NSMutableString alloc] initWithString:name];
|
||||
_name = [name mutableCopy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)appendStringToName:(NSString *)string
|
||||
{
|
||||
if (_name == nil) {
|
||||
_name = [NSMutableString new];
|
||||
}
|
||||
[_name appendString:string];
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,16 @@
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_tagName = [[NSMutableString alloc] initWithString:tagName];
|
||||
_tagName = [tagName mutableCopy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)appendStringToTagName:(NSString *)string
|
||||
{
|
||||
if (_tagName == nil) {
|
||||
_tagName = [NSMutableString new];
|
||||
}
|
||||
[_tagName appendString:string];
|
||||
}
|
||||
|
||||
@@ -68,7 +71,7 @@
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%@: %p TagName=%@>", self.class, self, self.tagName];
|
||||
return [NSString stringWithFormat:@"<%@: %p TagName=%@ Attributes=%@>", self.class, self, self.tagName, self.attributes];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -102,7 +105,7 @@
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%@: %p TagName=%@>", self.class, self, self.tagName];
|
||||
return [NSString stringWithFormat:@"<%@: %p TagName=%@ Attributes=%@>", self.class, self, self.tagName, self.attributes];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user