script: Handle shadow roots when determining common ancestors of dirty roots. (#35132)

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-01-23 20:14:16 -05:00 committed by GitHub
parent 6195026db0
commit ac22157491
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View file

@ -606,8 +606,15 @@ impl Document {
ancestor.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, has_dirty_descendants);
has_dirty_descendants &= *ancestor != *new_dirty_root;
}
self.dirty_root
.set(Some(new_dirty_root.downcast::<Element>().unwrap()));
let maybe_shadow_host = new_dirty_root
.downcast::<ShadowRoot>()
.map(ShadowRootMethods::Host);
let new_dirty_root_element = new_dirty_root
.downcast::<Element>()
.or(maybe_shadow_host.as_deref());
self.dirty_root.set(new_dirty_root_element);
}
pub(crate) fn take_dirty_root(&self) -> Option<DomRoot<Element>> {