Fix clearing the stack of open elements for the "in table body" phase
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user