Use ordered dictionary for the HTML Element's attributes

This commit is contained in:
iska
2015-03-15 17:49:05 +01:00
parent e56c8dff90
commit 5897ff2c58
2 changed files with 15 additions and 5 deletions
+2 -2
View File
@@ -23,7 +23,7 @@
@property (nonatomic, copy) NSString *className;
- (instancetype)initWithTagName:(NSString *)tagName;
- (instancetype)initWithTagName:(NSString *)tagName attributes:(id)attributes;
- (instancetype)initWithTagName:(NSString *)tagName attributes:(id)attributes namespace:(HTMLNamespace)namespace;
- (instancetype)initWithTagName:(NSString *)tagName attributes:(NSDictionary *)attributes;
- (instancetype)initWithTagName:(NSString *)tagName attributes:(NSDictionary *)attributes namespace:(HTMLNamespace)namespace;
@end
+13 -3
View File
@@ -7,6 +7,13 @@
//
#import "HTMLElement.h"
#import "HTMLOrderedDictionary.h"
@interface HTMLElement ()
{
HTMLOrderedDictionary *_attributes;
}
@end
@implementation HTMLElement
@@ -20,17 +27,20 @@
return [self initWithTagName:tagName attributes:nil];
}
- (instancetype)initWithTagName:(NSString *)tagName attributes:(id)attributes
- (instancetype)initWithTagName:(NSString *)tagName attributes:(NSDictionary *)attributes
{
return [self initWithTagName:tagName attributes:attributes namespace:HTMLNamespaceHTML];
}
- (instancetype)initWithTagName:(NSString *)tagName attributes:(id)attributes namespace:(HTMLNamespace)namespace
- (instancetype)initWithTagName:(NSString *)tagName attributes:(NSDictionary *)attributes namespace:(HTMLNamespace)namespace
{
self = [super initWithName:tagName type:HTMLNodeElement];
if (self) {
_tagName = tagName;
#warning Attributes
_attributes = [HTMLOrderedDictionary new];
if (attributes != nil) {
[_attributes addEntriesFromDictionary:attributes];
}
_namespace = namespace;
}
return self;