LibWeb: Remove shadow roots from elements that are removed from the DOM

We currently create a shadow tree once for each DOM element that renders
with a shadow tree (e.g. <input>, <details>). If such an element is
removed from the DOM, we must remove its shadow tree. Otherwise, the
shadow tree will refer to the old document in perpetuity.

If the node is added back to a DOM, then recreate the shadow tree.
This commit is contained in:
Timothy Flynn 2023-11-29 18:22:16 -05:00 committed by Sam Atkins
parent 3cde479416
commit ff48b7333c
Notes: sideshowbarker 2024-07-16 18:26:46 +09:00
12 changed files with 67 additions and 3 deletions

View file

@ -1003,6 +1003,11 @@ void HTMLInputElement::form_associated_element_was_inserted()
create_shadow_tree_if_needed();
}
void HTMLInputElement::form_associated_element_was_removed(DOM::Node*)
{
set_shadow_root(nullptr);
}
// https://html.spec.whatwg.org/multipage/input.html#radio-button-group
static bool is_in_same_radio_button_group(HTML::HTMLInputElement const& a, HTML::HTMLInputElement const& b)
{