diff --git a/HTMLKit/HTMLDOM.h b/HTMLKit/HTMLDOM.h
index f0ffa0e..4e9d5ce 100644
--- a/HTMLKit/HTMLDOM.h
+++ b/HTMLKit/HTMLDOM.h
@@ -9,8 +9,8 @@
#import "HTMLNode.h"
#import "HTMLDocument.h"
#import "HTMLDocumentType.h"
+#import "HTMLDocumentFragment.h"
#import "HTMLElement.h"
#import "HTMLComment.h"
#import "HTMLText.h"
#import "HTMLTemplate.h"
-#import "HTMLDocumentFragment.h"
diff --git a/HTMLKit/HTMLDocument.m b/HTMLKit/HTMLDocument.m
index 8a5329f..7ae4e68 100644
--- a/HTMLKit/HTMLDocument.m
+++ b/HTMLKit/HTMLDocument.m
@@ -72,7 +72,7 @@
return nil;
}
- if (node.type == HTMLNodeDocument) {
+ if (node.nodeType == HTMLNodeDocument) {
[NSException raise:HTMLKitNotSupportedError
format:@"%@: Not Fount Error, adopting a document node. The operation is not supported.", NSStringFromSelector(_cmd)];
}
diff --git a/HTMLKit/HTMLDocumentFragment.m b/HTMLKit/HTMLDocumentFragment.m
index 6b549a8..adcde5e 100644
--- a/HTMLKit/HTMLDocumentFragment.m
+++ b/HTMLKit/HTMLDocumentFragment.m
@@ -33,7 +33,7 @@
{
NSMutableString *content = [NSMutableString string];
for (HTMLNode *node in self.treeEnumerator) {
- if (node.type == HTMLNodeText) {
+ if (node.nodeType == HTMLNodeText) {
[content appendString:[(HTMLText *)node data]];
}
}
diff --git a/HTMLKit/HTMLElement.m b/HTMLKit/HTMLElement.m
index 11f0138..8e9a18f 100644
--- a/HTMLKit/HTMLElement.m
+++ b/HTMLKit/HTMLElement.m
@@ -89,7 +89,7 @@
{
NSMutableString *content = [NSMutableString string];
for (HTMLNode *node in self.treeEnumerator) {
- if (node.type == HTMLNodeText) {
+ if (node.nodeType == HTMLNodeText) {
[content appendString:[(HTMLText *)node data]];
}
}
@@ -146,7 +146,7 @@
return result;
}
- if ([self.tagName isEqualToAny:@"pre", @"textarea", @"listing", nil] && self.firstChiledNode.type == HTMLNodeText) {
+ if ([self.tagName isEqualToAny:@"pre", @"textarea", @"listing", nil] && self.firstChiledNode.nodeType == HTMLNodeText) {
HTMLText *textNode = (HTMLText *)self.firstChiledNode;
if ([textNode.data hasPrefix:@"\n"]) {
[result appendString:@"\n"];
diff --git a/HTMLKit/HTMLNode.h b/HTMLKit/HTMLNode.h
index f0d4c25..3c60f57 100644
--- a/HTMLKit/HTMLNode.h
+++ b/HTMLKit/HTMLNode.h
@@ -29,7 +29,7 @@ typedef NS_ENUM(short, HTMLNodeType)
@interface HTMLNode : NSObject
-@property (nonatomic, assign, readonly) HTMLNodeType type;
+@property (nonatomic, assign, readonly) HTMLNodeType nodeType;
@property (nonatomic, strong, readonly) NSString *name;
diff --git a/HTMLKit/HTMLNode.m b/HTMLKit/HTMLNode.m
index cc4f739..f0060f5 100644
--- a/HTMLKit/HTMLNode.m
+++ b/HTMLKit/HTMLNode.m
@@ -32,7 +32,7 @@
self = [super init];
if (self) {
_name = name;
- _type = type;
+ _nodeType = type;
_childNodes = [NSMutableOrderedSet new];
}
return self;
@@ -42,7 +42,7 @@
- (HTMLDocument *)ownerDocument
{
- if (_type == HTMLNodeDocument) {
+ if (_nodeType == HTMLNodeDocument) {
return (HTMLDocument *)self;
} else {
return _ownerDocument;
@@ -68,7 +68,7 @@
- (HTMLElement *)parentElement
{
- return _parentNode.type == HTMLNodeElement ? (HTMLElement *)_parentNode : nil;
+ return _parentNode.nodeType == HTMLNodeElement ? (HTMLElement *)_parentNode : nil;
}
- (HTMLNode *)firstChiledNode
@@ -121,7 +121,7 @@
- (BOOL)hasChildNodeOfType:(HTMLNodeType)type
{
NSUInteger index = [self.childNodes indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
- if ([(HTMLNode *)obj type] == type) {
+ if ([(HTMLNode *)obj nodeType] == type) {
*stop = YES;
return YES;
}
@@ -178,7 +178,7 @@
[self.ownerDocument adoptNode:node];
- NSArray *nodes = node.type == HTMLNodeDocumentFragment ? [NSArray arrayWithArray:node.childNodes.array] : @[node];
+ NSArray *nodes = node.nodeType == HTMLNodeDocumentFragment ? [NSArray arrayWithArray:node.childNodes.array] : @[node];
NSUInteger index = [self indexOfChildNode:child];
if (index != NSNotFound) {
@@ -188,7 +188,7 @@
[(NSMutableOrderedSet *)self.childNodes addObjectsFromArray:nodes];
}
- if (node.type == HTMLNodeDocumentFragment) {
+ if (node.nodeType == HTMLNodeDocumentFragment) {
[node removeAllChildNodes];
}
@@ -281,7 +281,7 @@
- (void)doInsertNode:(HTMLNode *)node beforeChildNode:(HTMLNode *)child
{
- NSArray *nodes = node.type == HTMLNodeDocumentFragment ? node.childNodes.array : @[node];
+ NSArray *nodes = node.nodeType == HTMLNodeDocumentFragment ? node.childNodes.array : @[node];
NSUInteger index = [self indexOfChildNode:child];
if (index != NSNotFound) {
@@ -298,9 +298,9 @@
NS_INLINE void CheckParentValid(HTMLNode *parent, NSString *cmd)
{
- if (parent.type != HTMLNodeDocument &&
- parent.type != HTMLNodeDocumentFragment &&
- parent.type != HTMLNodeElement) {
+ if (parent.nodeType != HTMLNodeDocument &&
+ parent.nodeType != HTMLNodeDocumentFragment &&
+ parent.nodeType != HTMLNodeElement) {
[NSException raise:HTMLKitHierarchyRequestError
format:@"%@: Hierarchy Request Error, inserting into %@ is not allowed. The operation would yield an incorrect node tree.",
cmd, parent.name];
@@ -319,11 +319,11 @@ NS_INLINE void CheckChildsParent(HTMLNode *parent, HTMLNode *child, NSString *cm
NS_INLINE void CheckInsertedNodeValid(HTMLNode *node, NSString *cmd)
{
- if (node.type != HTMLNodeDocumentFragment &&
- node.type != HTMLNodeDocumentType &&
- node.type != HTMLNodeElement &&
- node.type != HTMLNodeText &&
- node.type != HTMLNodeComment) {
+ if (node.nodeType != HTMLNodeDocumentFragment &&
+ node.nodeType != HTMLNodeDocumentType &&
+ node.nodeType != HTMLNodeElement &&
+ node.nodeType != HTMLNodeText &&
+ node.nodeType != HTMLNodeComment) {
[NSException raise:HTMLKitHierarchyRequestError
format:@"%@: Hierarchy Request Error, inserting a %@ is not allowed. The operation would yield an incorrect node tree.",
cmd, node.name];
@@ -332,13 +332,13 @@ NS_INLINE void CheckInsertedNodeValid(HTMLNode *node, NSString *cmd)
NS_INLINE void CheckInvalidCombination(HTMLNode *parent, HTMLNode *node, NSString *cmd)
{
- if (node.type == HTMLNodeText && parent.type == HTMLNodeDocument) {
+ if (node.nodeType == HTMLNodeText && parent.nodeType == HTMLNodeDocument) {
[NSException raise:HTMLKitHierarchyRequestError
format:@"%@: Hierarchy Request Error, inserting a text node %@ into docuement is not allowed. The operation would yield an incorrect node tree.",
cmd, parent.name];
}
- if (node.type == HTMLNodeDocumentType && parent.type != HTMLNodeDocument) {
+ if (node.nodeType == HTMLNodeDocumentType && parent.nodeType != HTMLNodeDocument) {
[NSException raise:HTMLKitHierarchyRequestError
format:@"%@: Hierarchy Request Error, inserting a doctype %@ into a non-document node is not allowed. The operation would yield an incorrect node tree.",
cmd, parent.name];
@@ -361,24 +361,24 @@ NS_INLINE void CheckInvalidCombination(HTMLNode *parent, HTMLNode *node, NSStrin
NSStringFromSelector(_cmd), self, node];
};
- if (self.type == HTMLNodeDocument) {
- switch (node.type) {
+ if (self.nodeType == HTMLNodeDocument) {
+ switch (node.nodeType) {
case HTMLNodeDocumentFragment:
if (node.childNodesCount > 1 ||
[node hasChildNodeOfType:HTMLNodeText]) {
hierarchyError();
} else if (node.childNodesCount == 1) {
if ([self hasChildNodeOfType:HTMLNodeElement] ||
- child.type == HTMLNodeDocumentType ||
- child.nextSibling.type == HTMLNodeDocumentType) {
+ child.nodeType == HTMLNodeDocumentType ||
+ child.nextSibling.nodeType == HTMLNodeDocumentType) {
hierarchyError();
}
}
break;
case HTMLNodeElement:
if ([self hasChildNodeOfType:HTMLNodeElement] ||
- child.type == HTMLNodeDocumentType ||
- (child != nil && child.nextSibling.type == HTMLNodeDocumentType)) {
+ child.nodeType == HTMLNodeDocumentType ||
+ (child != nil && child.nextSibling.nodeType == HTMLNodeDocumentType)) {
hierarchyError();
}
break;
@@ -413,21 +413,21 @@ NS_INLINE void CheckInvalidCombination(HTMLNode *parent, HTMLNode *node, NSStrin
void (^ checkParentHasAnotherChildOfType)(HTMLNodeType) = ^ void (HTMLNodeType type) {
[self enumerateChildNodesUsingBlock:^(HTMLNode *node, NSUInteger idx, BOOL *stop) {
- if (node.type == type && node != child) {
+ if (node.nodeType == type && node != child) {
*stop = YES;
hierarchyError();
}
}];
};
- if (self.type == HTMLNodeDocument) {
- switch (node.type) {
+ if (self.nodeType == HTMLNodeDocument) {
+ switch (node.nodeType) {
case HTMLNodeDocumentFragment:
if (node.childNodesCount > 1 ||
[node hasChildNodeOfType:HTMLNodeText]) {
hierarchyError();
} else if (node.childNodesCount == 1) {
- if (child.nextSibling.type == HTMLNodeDocumentType) {
+ if (child.nextSibling.nodeType == HTMLNodeDocumentType) {
hierarchyError();
}
checkParentHasAnotherChildOfType(HTMLNodeElement);
@@ -435,7 +435,7 @@ NS_INLINE void CheckInvalidCombination(HTMLNode *parent, HTMLNode *node, NSStrin
break;
case HTMLNodeElement:
{
- if (child.nextSibling.type == HTMLNodeDocumentType) {
+ if (child.nextSibling.nodeType == HTMLNodeDocumentType) {
hierarchyError();
}
checkParentHasAnotherChildOfType(HTMLNodeElement);
@@ -443,7 +443,7 @@ NS_INLINE void CheckInvalidCombination(HTMLNode *parent, HTMLNode *node, NSStrin
}
case HTMLNodeDocumentType:
{
- if (child.previousSibling.type == HTMLNodeElement) {
+ if (child.previousSibling.nodeType == HTMLNodeElement) {
hierarchyError();
}
checkParentHasAnotherChildOfType(HTMLNodeDocumentType);
@@ -461,7 +461,7 @@ NS_INLINE void CheckInvalidCombination(HTMLNode *parent, HTMLNode *node, NSStrin
- (id)copyWithZone:(NSZone *)zone
{
- HTMLNode *copy = [[self.class alloc] initWithName:self.name type:self.type];
+ HTMLNode *copy = [[self.class alloc] initWithName:self.name type:self.nodeType];
return copy;
}
diff --git a/HTMLKit/HTMLParser.m b/HTMLKit/HTMLParser.m
index f5f0ed5..539ce36 100644
--- a/HTMLKit/HTMLParser.m
+++ b/HTMLKit/HTMLParser.m
@@ -12,7 +12,7 @@
#import "HTMLStackOfOpenElements.h"
#import "HTMLListOfActiveFormattingElements.h"
#import "HTMLParserInsertionModes.h"
-#import "HTMLNodes.h"
+#import "HTMLDOM.h"
#import "HTMLElementTypes.h"
#import "HTMLElementAdjustment.h"
#import "HTMLMarker.h"
@@ -452,10 +452,10 @@
HTMLElement *child = nil;
HTMLNode *adjustedInsertionLocation = [self appropriatePlaceForInsertingANodeWithOverrideTarget:nil
beforeChildNode:&child];
- if (adjustedInsertionLocation.type != HTMLNodeDocument) {
- if (child != nil && child.previousSibling.type == HTMLNodeText) {
+ if (adjustedInsertionLocation.nodeType != HTMLNodeDocument) {
+ if (child != nil && child.previousSibling.nodeType == HTMLNodeText) {
[(HTMLText *)child.previousSibling appendString:data];
- } else if (adjustedInsertionLocation.lastChildNode.type == HTMLNodeText) {
+ } else if (adjustedInsertionLocation.lastChildNode.nodeType == HTMLNodeText) {
[(HTMLText *)adjustedInsertionLocation.lastChildNode appendString:data];
} else {
HTMLText *text = [[HTMLText alloc] initWithData:data];
diff --git a/HTMLKitTests/HTMLKitNodesTests.m b/HTMLKitTests/HTMLKitNodesTests.m
index 5bb051a..8e499de 100644
--- a/HTMLKitTests/HTMLKitNodesTests.m
+++ b/HTMLKitTests/HTMLKitNodesTests.m
@@ -30,7 +30,7 @@
HTMLNode *node = [[HTMLNode alloc] initWithName:@"name" type:HTMLNodeElement];
XCTAssertNotNil(node);
XCTAssertEqualObjects(node.name, @"name");
- XCTAssertEqual(node.type, HTMLNodeElement);
+ XCTAssertEqual(node.nodeType, HTMLNodeElement);
XCTAssertNotNil(node.childNodes);
XCTAssertEqual(node.childNodes.count, 0);
diff --git a/HTMLKitTests/HTMLKitTreeConstructionTests.m b/HTMLKitTests/HTMLKitTreeConstructionTests.m
index cfb7430..ca1f223 100644
--- a/HTMLKitTests/HTMLKitTreeConstructionTests.m
+++ b/HTMLKitTests/HTMLKitTreeConstructionTests.m
@@ -9,7 +9,7 @@
#import
#import "HTML5LibTreeConstructionTest.h"
-#import "HTMLNodes.h"
+#import "HTMLDOM.h"
#import "HTMLParser.h"
@@ -121,14 +121,14 @@
{
XCTAssertEqualObjects(actual.name, expected.name, @"Node name mismatch [%@ should be %@]:\n%@",
actual.name, expected.name, message);
- XCTAssert(actual.type == expected.type, @"Node type mismatch [%hd should be %hd]:\n%@",
- actual.type, expected.type, message);
+ XCTAssert(actual.nodeType == expected.nodeType, @"Node type mismatch [%hd should be %hd]:\n%@",
+ actual.nodeType, expected.nodeType, message);
- if (actual.type != expected.type) {
+ if (actual.nodeType != expected.nodeType) {
return;
}
- switch (actual.type) {
+ switch (actual.nodeType) {
case HTMLNodeDocumentType:
XCTAssertEqualObjects([(HTMLDocumentType *)actual publicIdentifier], [(HTMLDocumentType *)expected publicIdentifier], @"%@", message);
XCTAssertEqualObjects([(HTMLDocumentType *)actual systemIdentifier], [(HTMLDocumentType *)expected systemIdentifier], @"%@", message);