From e2e49401000e586db7ba2dfa1de777a7d77a83ed Mon Sep 17 00:00:00 2001 From: iska Date: Thu, 30 Oct 2014 21:18:15 +0100 Subject: [PATCH] Add implementation for finalising the current attribute of the current Tag Token --- HTMLKit/HTMLTokenizer.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/HTMLKit/HTMLTokenizer.m b/HTMLKit/HTMLTokenizer.m index 9037e2e..aefbbad 100644 --- a/HTMLKit/HTMLTokenizer.m +++ b/HTMLKit/HTMLTokenizer.m @@ -214,7 +214,19 @@ - (void)finalizeCurrentAttribute { -#warning Implement attributes for Tag Tokens + if (_currentAttributeName != nil) { + if (_currentTagToken.attributes == nil) { + _currentTagToken.attributes = [NSMutableDictionary new]; + } + + if (_currentTagToken.attributes[_currentAttributeName] != nil) { + [self emitParseError:@"Tag token [%@] already contains an attrbitue with name [%@]", _currentTagToken, _currentAttributeName]; + } else { + _currentTagToken.attributes[_currentAttributeName] = _currentAttributeValue ?: @""; + } + } + _currentAttributeName = nil; + _currentAttributeValue = nil; } #pragma mark - Consume Character Reference