LibWeb: Invalidate entire layout tree on SVG <use> clone instantiation

This is sub-optimal but let's rebuild the whole tree for now, since this
case gets quite complicated and there are more valuable things to chase
after first.

Thanks to Gingeh for the reduced test case!
This commit is contained in:
Andreas Kling 2025-01-19 12:00:40 +01:00 committed by Andreas Kling
parent 6a564376fc
commit ceb6348811
Notes: github-actions[bot] 2025-01-19 13:39:08 +00:00
3 changed files with 14 additions and 0 deletions

View file

@ -183,6 +183,9 @@ void SVGUseElement::clone_element_tree_as_our_shadow_tree(Element* to_clone)
auto cloned_reference_node = MUST(to_clone->clone_node(nullptr, true));
shadow_root()->append_child(cloned_reference_node).release_value_but_fixme_should_propagate_errors();
}
// FIXME: Only invalidate the part of the layout tree that is affected by this change.
document().invalidate_layout_tree();
}
bool SVGUseElement::is_valid_reference_element(Element const& reference_element) const

View file

@ -0,0 +1 @@
PASS (didn't fall apart)

View file

@ -0,0 +1,10 @@
<script src="../include.js"></script>
<svg><symbol id="foo"></symbol><use href="#foo"></use></svg>
<script>
test(() => {
document.body.offsetWidth; // force layout
foo.setAttribute("id", "bar");
document.body.offsetWidth; // force layout
println("PASS (didn't fall apart)");
});
</script>