Use managed ivars for public and system identifiers in Document Type node
- If either is nil an empty string is return on getter-call - nil value indicates a missing identifier, an empty string is not considered missing in some parsing cases
This commit is contained in:
@@ -12,6 +12,13 @@ NS_INLINE BOOL nilOrEqual(id first, id second) {
|
||||
return (first == nil) || ([first isEqual:second]);
|
||||
}
|
||||
|
||||
@interface HTMLDocumentType ()
|
||||
{
|
||||
NSString *_publicIdentifier;
|
||||
NSString *_systemIdentifier;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation HTMLDocumentType
|
||||
|
||||
- (instancetype)initWithName:(NSString *)name
|
||||
@@ -20,12 +27,22 @@ NS_INLINE BOOL nilOrEqual(id first, id second) {
|
||||
{
|
||||
self = [super initWithName:name type:HTMLNodeDocumentType];
|
||||
if (self) {
|
||||
_publicIdentifier = [publicIdentifier copy] ?: @"";
|
||||
_systemIdentifier = [systemIdentifier copy] ?: @"";
|
||||
_publicIdentifier = [publicIdentifier copy];
|
||||
_systemIdentifier = [systemIdentifier copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)publicIdentifier
|
||||
{
|
||||
return _publicIdentifier ?: @"";
|
||||
}
|
||||
|
||||
- (NSString *)systemIdentifier
|
||||
{
|
||||
return _systemIdentifier ?: @"";
|
||||
}
|
||||
|
||||
- (BOOL)isValid
|
||||
{
|
||||
if (![self.name isEqualToString:@"html"]) {
|
||||
|
||||
Reference in New Issue
Block a user