From 32dd4bf1b998264cb06b18d264cd34b56365feca Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 14 Mar 2022 12:54:41 +0100 Subject: [PATCH] LibWeb: Recurse into shadow trees when updating style The style update mechanism was happily ignoring shadow subtrees. Fix this by checking if an element has a shadow root, and recursing into it if needed. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index b71b42c237..6a022a0181 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -602,6 +602,12 @@ static void update_style_recursively(DOM::Node& node) node.set_needs_style_update(false); if (node.child_needs_style_update()) { + if (node.is_element()) { + if (auto* shadow_root = static_cast(node).shadow_root()) { + if (shadow_root->needs_style_update() || shadow_root->child_needs_style_update()) + update_style_recursively(*shadow_root); + } + } node.for_each_child([&](auto& child) { if (child.needs_style_update() || child.child_needs_style_update()) update_style_recursively(child);