LibWeb: Add spec comment for HTMLParser::adjusted_current_node

I've found myself looking at this function a bunch while debugging.
This commit is contained in:
Shannon Booth 2023-10-04 07:58:36 +13:00 committed by Sam Atkins
parent 0a8eb59a05
commit 907be5a96e

View file

@ -579,8 +579,13 @@ DOM::Element& HTMLParser::current_node()
return m_stack_of_open_elements.current_node();
}
// https://html.spec.whatwg.org/multipage/parsing.html#adjusted-current-node
DOM::Element& HTMLParser::adjusted_current_node()
{
// The adjusted current node is the context element if the parser was created as part of the
// HTML fragment parsing algorithm and the stack of open elements has only one element in it
// (fragment case); otherwise, the adjusted current node is the current node.
if (m_parsing_fragment && m_stack_of_open_elements.elements().size() == 1)
return *m_context_element;