Add parser method for inserting Comment nodes into the document
https://html.spec.whatwg.org/multipage/syntax.html#insert-a-comment
This commit is contained in:
+15
-3
@@ -9,9 +9,8 @@
|
||||
#import "HTMLParser.h"
|
||||
#import "HTMLTokenizer.h"
|
||||
#import "HTMLTokens.h"
|
||||
#import "HTMLCharacterToken.h"
|
||||
#import "HTMLParserInsertionModes.h"
|
||||
#import "HTMLElement.h"
|
||||
#import "HTMLNodes.h"
|
||||
#import "HTMLElementTypes.h"
|
||||
|
||||
@interface HTMLParser ()
|
||||
@@ -26,6 +25,8 @@
|
||||
|
||||
NSMutableArray *_stackOfOpenElements;
|
||||
|
||||
HTMLDocument *_document;
|
||||
|
||||
HTMLElement *_contextElement;
|
||||
HTMLElement *_currentElement;
|
||||
|
||||
@@ -292,7 +293,7 @@
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (HTMLElement *)appropriatePlaceForInsertingANodeWithOverrideTarget:(id)overrideTarget
|
||||
- (HTMLNode *)appropriatePlaceForInsertingANodeWithOverrideTarget:(HTMLElement *)overrideTarget
|
||||
{
|
||||
HTMLElement *target = self.currentNode;
|
||||
if (overrideTarget == nil) {
|
||||
@@ -331,6 +332,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)insertComment:(HTMLCommentToken *)token asChildOfNode:(HTMLNode *)node
|
||||
{
|
||||
HTMLNode *parent = node;
|
||||
if (parent == nil) {
|
||||
parent = [self appropriatePlaceForInsertingANodeWithOverrideTarget:nil];
|
||||
}
|
||||
|
||||
HTMLComment *comment = [[HTMLComment alloc] initWithData:token.data];
|
||||
[parent appendChildNode:comment];
|
||||
}
|
||||
|
||||
#pragma mark - Insertion Modes
|
||||
|
||||
- (void)HTMLInsertionModeInitial:(HTMLToken *)token
|
||||
|
||||
Reference in New Issue
Block a user