Skip to content

Commit 751b678

Browse files
Support “generate all implied end tags thoroughly”
When the parser encounters a `</template>` end tag and there are other open elements, the HTML spec requires the parser to “generate all implied end tags thoroughly”, which unlike “generate implied end tags” also includes generating implied end tags for table-parts elements (caption, colgroup, tbody, thead, tfoot, td, th, and tr).
1 parent 303dcc8 commit 751b678

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/nu/validator/htmlparser/impl/TreeBuilder.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4089,7 +4089,7 @@ private void endTagTemplateInHead() throws SAXException {
40894089
errStrayEndTag("template");
40904090
return;
40914091
}
4092-
generateImpliedEndTags();
4092+
generateImpliedEndTagsThoroughly();
40934093
if (errorHandler != null && !isCurrent("template")) {
40944094
errUnclosedElements(eltPos, "template");
40954095
}
@@ -4230,6 +4230,29 @@ private void generateImpliedEndTags() throws SAXException {
42304230
}
42314231
}
42324232

4233+
private void generateImpliedEndTagsThoroughly() throws SAXException {
4234+
for (;;) {
4235+
switch (stack[currentPtr].getGroup()) {
4236+
case CAPTION:
4237+
case COLGROUP:
4238+
case DD_OR_DT:
4239+
case LI:
4240+
case OPTGROUP:
4241+
case OPTION:
4242+
case P:
4243+
case RB_OR_RTC:
4244+
case RT_OR_RP:
4245+
case TBODY_OR_THEAD_OR_TFOOT:
4246+
case TD_OR_TH:
4247+
case TR:
4248+
pop();
4249+
continue;
4250+
default:
4251+
return;
4252+
}
4253+
}
4254+
}
4255+
42334256
private boolean isSecondOnStackBody() {
42344257
return currentPtr >= 1 && stack[1].getGroup() == TreeBuilder.BODY;
42354258
}

0 commit comments

Comments
 (0)