swc-project/swc · error · Error
UnclosedElementsImplied
UnclosedElementsImplied
Error message
End tag "li" implied, but there were open elements
What it means
HTML parse error while handling an <li> start tag: implied end tags were generated for the previous list item, but the stack of open elements still contained unexpected open elements at that point (current node was not an li after the loop), indicating malformed list nesting. Parsing recovers by popping to the li.
Source
Thrown at crates/swc_html_parser/src/parser/mod.rs:2930
is_self_closing,
..
} if tag_name == "li" => {
self.frameset_ok = false;
// Initialise node to be the current node (the bottommost node of
// the stack).
// Step "Loop".
for node in self.open_elements_stack.items.iter().rev() {
if is_html_element!(node, "li") {
// Generate implied end tags, except for li elements.
self.open_elements_stack
.generate_implied_end_tags_with_exclusion("li");
// If the current node is not an li element, then this is a
// parse error.
match self.open_elements_stack.items.last() {
Some(node) if !is_html_element!(node, "li") => {
self.errors.push(Error::new(
token_and_info.span,
ErrorKind::UnclosedElementsImplied(atom!("li")),
));
}
_ => {}
}
// Pop elements from the stack of open elements until an li
// element has been popped from the stack.
self.open_elements_stack.pop_until_tag_name_popped(&["li"]);
// Jump to the step labeled done below.
break;
}
// If node is in the special category, but is not an address,
// div, or p element, then jump to the step labeled done below.
// Otherwise, set node to the previous entry in the stackView on GitHub (pinned to 5176682b65)
Solutions
- Properly close <li> items and intervening elements before the next <li>
- Fix broken nesting (e.g. unclosed <p> or <div> inside the list)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_html_parser/src/parser/mod.rs:2930 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/a1dda4a7cead84ca.
Report an issue: GitHub.