Fix clearing the stack of open elements for the "in table body" phase

This commit is contained in:
iska
2015-03-22 00:13:55 +01:00
parent 90cbccbc16
commit e95d45b534
3 changed files with 11 additions and 5 deletions
+3 -3
View File
@@ -1767,7 +1767,7 @@
[self emitParseError:@"Unexpected Tag Token (%@) for element in <tbody>", token.asTagToken.tagName];
return;
} else {
[_stackOfOpenElements clearBackToTableContext];
[_stackOfOpenElements clearBackToTableBodyContext];
[_stackOfOpenElements popCurrentNode];
[self switchInsertionMode:HTMLInsertionModeInTable];
}
@@ -1780,12 +1780,12 @@
switch (token.type) {
case HTMLTokenTypeStartTag:
if ([token.asTagToken.tagName isEqualToString:@"tr"]) {
[_stackOfOpenElements clearBackToTableContext];
[_stackOfOpenElements clearBackToTableBodyContext];
[self insertElementForToken:token.asTagToken];
[self switchInsertionMode:HTMLInsertionModeInRow];
} else if ([token.asTagToken.tagName isEqualToAny:@"th", @"td", nil]) {
[self emitParseError:@"Unexpected Start Tag Token (%@) in <tbody>", token.asTagToken.tagName];
[_stackOfOpenElements clearBackToTableContext];
[_stackOfOpenElements clearBackToTableBodyContext];
HTMLStartTagToken *trToken = [[HTMLStartTagToken alloc] initWithTagName:@"tr"];
[self insertElementForToken:trToken];
[self switchInsertionMode:HTMLInsertionModeInRow];
+1 -1
View File
@@ -31,9 +31,9 @@
- (void)popElementsUntilAnElementPoppedWithAnyOfTagNames:(NSArray *)tagNames;
- (void)popElementsUntilElementPopped:(HTMLElement *)element;
- (void)clearBackToTableContext;
- (void)clearBackToTableBodyContext;
- (void)popAll;
- (HTMLElement *)hasElementInScopeWithTagName:(NSString *)tagName;
- (HTMLElement *)hasAnyElementInScopeWithAnyOfTagNames:(NSArray *)tagNames;
- (HTMLElement *)hasElementInListItemScopeWithTagName:(NSString *)tagName;
+7 -1
View File
@@ -24,6 +24,7 @@
{
self = [super init];
if (self) {
_stack = [NSMutableArray new];
_specificScopeElementTypes = @{
@"applet": @(HTMLNamespaceHTML),
@"caption": @(HTMLNamespaceHTML),
@@ -138,7 +139,12 @@
- (void)clearBackToTableContext
{
while (![self.currentNode.tagName isEqualToAny:@"table", @"template", @"html", nil]) {
}
- (void)clearBackToTableBodyContext
{
while (![self.currentNode.tagName isEqualToAny:@"tbody", @"tfoot", @"thead", @"template", @"html", nil]) {
[_stack removeLastObject];
}
}