Skip to content

Commit ae7119f

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 31ba78f commit ae7119f

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
@@ -3884,7 +3884,7 @@ private void endTagTemplateInHead() throws SAXException {
38843884
errStrayEndTag("template");
38853885
return;
38863886
}
3887-
generateImpliedEndTags();
3887+
generateImpliedEndTagsThoroughly();
38883888
if (errorHandler != null && !isCurrent("template")) {
38893889
errUnclosedElements(eltPos, "template");
38903890
}
@@ -4025,6 +4025,29 @@ private void generateImpliedEndTags() throws SAXException {
40254025
}
40264026
}
40274027

4028+
private void generateImpliedEndTagsThoroughly() throws SAXException {
4029+
for (;;) {
4030+
switch (stack[currentPtr].getGroup()) {
4031+
case CAPTION:
4032+
case COLGROUP:
4033+
case DD_OR_DT:
4034+
case LI:
4035+
case OPTGROUP:
4036+
case OPTION:
4037+
case P:
4038+
case RB_OR_RTC:
4039+
case RT_OR_RP:
4040+
case TBODY_OR_THEAD_OR_TFOOT:
4041+
case TD_OR_TH:
4042+
case TR:
4043+
pop();
4044+
continue;
4045+
default:
4046+
return;
4047+
}
4048+
}
4049+
}
4050+
40284051
private boolean isSecondOnStackBody() {
40294052
return currentPtr >= 1 && stack[1].getGroup() == TreeBuilder.BODY;
40304053
}

0 commit comments

Comments
 (0)