Add implementation for inserting character tokens (strings) into the DOM
https://html.spec.whatwg.org/multipage/syntax.html#insert-a-character
This commit is contained in:
@@ -320,7 +320,12 @@
|
||||
HTMLNode *adjustedInsertionLocation = [self appropriatePlaceForInsertingANodeWithOverrideTarget:nil
|
||||
beforeChildNode:&child];
|
||||
if (adjustedInsertionLocation.type != HTMLNodeDocument) {
|
||||
#warning Implement inserting string into node (https://html.spec.whatwg.org/multipage/syntax.html#insert-a-character)
|
||||
if (adjustedInsertionLocation.lastChildNode.type == HTMLNodeText) {
|
||||
[(HTMLText *)adjustedInsertionLocation.lastChildNode appendString:data];
|
||||
} else {
|
||||
HTMLText *text = [[HTMLText alloc] initWithData:data];
|
||||
[adjustedInsertionLocation insertNode:text beforeChildNode:child];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,4 +14,6 @@
|
||||
|
||||
- (instancetype)initWithData:(NSString *)data;
|
||||
|
||||
- (void)appendString:(NSString *)string;
|
||||
|
||||
@end
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
[self.data setString:textContent ?: @""];
|
||||
}
|
||||
|
||||
- (void)appendString:(NSString *)string
|
||||
{
|
||||
[self.data appendString:string];
|
||||
}
|
||||
|
||||
#pragma mark - NSCopying
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone
|
||||
|
||||
Reference in New Issue
Block a user