LibWeb: Set doctype node immediately while parsing XML document

Instead of deferring it to the end of parsing, where scripts that
were expecting to look at the doctype may have already run.
This commit is contained in:
Andreas Kling
2024-11-20 11:43:20 +01:00
committed by Andreas Kling
parent ab0dc83d28
commit cd446e5e9c
6 changed files with 66 additions and 9 deletions

View File

@@ -182,9 +182,6 @@ ErrorOr<void, ParseError> Parser::parse_with_listener(Listener& listener)
if (result.is_error())
m_listener->error(result.error());
m_listener->document_end();
if (m_doctype.has_value()) {
m_listener->set_doctype(m_doctype.release_value());
}
m_root_node.clear();
return result;
}
@@ -621,7 +618,8 @@ ErrorOr<void, ParseError> Parser::parse_doctype_decl()
TRY(expect(">"sv));
rollback.disarm();
m_doctype = move(doctype);
if (m_listener)
m_listener->doctype(doctype);
return {};
}