From a28580b258c12a2025cbd7cd9d80e4f1b0bdeb54 Mon Sep 17 00:00:00 2001 From: iska Date: Thu, 30 Oct 2014 21:18:56 +0100 Subject: [PATCH] Fix initialisation of HTML5 Lib tests Checks for nil values and inits accordingly --- HTMLKitTests/HTML5LibTest.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/HTMLKitTests/HTML5LibTest.m b/HTMLKitTests/HTML5LibTest.m index 81eb1cc..be45672 100644 --- a/HTMLKitTests/HTML5LibTest.m +++ b/HTMLKitTests/HTML5LibTest.m @@ -92,9 +92,10 @@ } else if ([type isEqualToString:@"Comment"]) { return [[HTMLCommentToken alloc] initWithData:data]; } else if ([type isEqualToString:@"DOCTYPE"]) { + data = [[NSNull null] isEqualTo:data] ? nil : data; HTMLDOCTYPEToken *token = [[HTMLDOCTYPEToken alloc] initWithName:data]; - token.publicIdentifier = [[NSNull null] isEqual:output[2]] ? nil : output[2]; - token.systemIdentifier = [[NSNull null] isEqual:output[3]] ? nil : output[3]; + token.publicIdentifier = [[NSNull null] isEqualTo:output[2]] ? nil : output[2]; + token.systemIdentifier = [[NSNull null] isEqualTo:output[3]] ? nil : output[3]; token.forceQuirks = ([output[4] boolValue] == NO); return token; } else if ([type isEqualToString:@"EndTag"]) { @@ -104,6 +105,9 @@ } else if ([type isEqualToString:@"StartTag"]) { HTMLStartTagToken *token = [[HTMLStartTagToken alloc] initWithTagName:data]; NSDictionary *attributes = output[2]; + if (attributes && attributes.allKeys.count > 0) { + token.attributes = [NSMutableDictionary new]; + } for (NSString *name in attributes) { NSString *value = [attributes objectForKey:name]; [token.attributes setObject:value forKey:name];