@@ -748,29 +748,30 @@ HTMLParser::AdjustedInsertionLocation HTMLParser::find_appropriate_place_for_ins
748748 // 3. If there is a last template and either there is no last table,
749749 // or there is one, but last template is lower (more recently added) than last table in the stack of open elements,
750750 if (last_template.element && (!last_table.element || last_template.index > last_table.index )) {
751- // then: let adjusted insertion location be inside last template's template contents, after its last child (if any), and abort these steps.
751+ // then: let adjusted insertion location be inside last template's template contents, after its last child
752+ // (if any), and abort these steps.
752753
753754 // NOTE: This returns the template content, so no need to check the parent is a template.
754755 return { as<HTMLTemplateElement>(*last_template.element ).content ().ptr (), nullptr };
755756 }
756- // 4. If there is no last table, then let adjusted insertion location be inside the first element in the stack of open elements (the html element),
757- // after its last child (if any), and abort these steps. (fragment case)
757+ // 4. If there is no last table, then let adjusted insertion location be inside the first element in the stack
758+ // of open elements (the html element), after its last child (if any), and abort these steps. (fragment case)
758759 if (!last_table.element ) {
759760 VERIFY (m_parsing_fragment);
760761 // Guaranteed not to be a template element (it will be the html element),
761762 // so no need to check the parent is a template.
762763 return { *m_stack_of_open_elements.elements ().first (), nullptr };
763764 }
764- // 5. If last table has a parent node, then let adjusted insertion location be inside last table's parent node, immediately before last table, and abort these steps.
765- if (last_table.element ->parent_node ()) {
766- adjusted_insertion_location = { last_table.element ->parent_node (), last_table.element .ptr () };
767- } else {
768- // 6. Let previous element be the element immediately above last table in the stack of open elements.
769- auto previous_element = m_stack_of_open_elements.element_immediately_above (*last_table.element );
765+ // 5. If last table has a parent node, then let adjusted insertion location be inside last table's parent node,
766+ // immediately before last table, and abort these steps.
767+ if (last_table.element ->parent_node ())
768+ return { last_table.element ->parent_node (), last_table.element .ptr () };
770769
771- // 7. Let adjusted insertion location be inside previous element, after its last child (if any).
772- adjusted_insertion_location = { previous_element.ptr (), nullptr };
773- }
770+ // 6. Let previous element be the element immediately above last table in the stack of open elements.
771+ auto previous_element = m_stack_of_open_elements.element_immediately_above (*last_table.element );
772+
773+ // 7. Let adjusted insertion location be inside previous element, after its last child (if any).
774+ adjusted_insertion_location = { previous_element.ptr (), nullptr };
774775 } else {
775776 // `-> Otherwise
776777 // Let adjusted insertion location be inside target, after its last child (if any).
0 commit comments