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:
iska
2015-03-19 01:30:47 +01:00
parent 9858efa611
commit 1164609bcf
3 changed files with 13 additions and 1 deletions
+6 -1
View File
@@ -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];
}
}
}
+2
View File
@@ -14,4 +14,6 @@
- (instancetype)initWithData:(NSString *)data;
- (void)appendString:(NSString *)string;
@end
+5
View File
@@ -35,6 +35,11 @@
[self.data setString:textContent ?: @""];
}
- (void)appendString:(NSString *)string
{
[self.data appendString:string];
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone