diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 7f76f6d343..b33dd01881 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -529,6 +529,14 @@ void Node::set_document(Badge, Document& document) document.ref_from_node({}); m_document->unref_from_node({}); m_document = &document; + + if (needs_style_update() || child_needs_style_update()) { + // NOTE: We unset and reset the "needs style update" flag here. + // This ensures that there's a pending style update in the new document + // that will eventually assign some style to this node if needed. + set_needs_style_update(false); + set_needs_style_update(true); + } } bool Node::is_editable() const