From 35671d9dde0f18074aecbc8c474e760223617a39 Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Sat, 25 Apr 2026 17:12:45 +0800 Subject: [PATCH] pls don't panic Signed-off-by: Euclid Ye --- components/script/dom/document/document.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/components/script/dom/document/document.rs b/components/script/dom/document/document.rs index e7d3e555731..55f39464faf 100644 --- a/components/script/dom/document/document.rs +++ b/components/script/dom/document/document.rs @@ -710,14 +710,16 @@ impl Document { self.root_removal_noted.set(false); if let Some(dirty_root) = self.dirty_root.get() { - // There was an existing dirty root so we mark its - // ancestors as dirty until the document element. - for ancestor in dirty_root - .upcast::() - .inclusive_ancestors_in_flat_tree() - { - if ancestor.is::() { - ancestor.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, true); + if dirty_root.is_connected() { + // There was an existing dirty root so we mark its + // ancestors as dirty until the document element. + for ancestor in dirty_root + .upcast::() + .inclusive_ancestors_in_flat_tree() + { + if ancestor.is::() { + ancestor.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, true); + } } } }