diff --git a/crates/js/src/vm.rs b/crates/js/src/vm.rs index eee3a41..3bf67be 100644 --- a/crates/js/src/vm.rs +++ b/crates/js/src/vm.rs @@ -1995,6 +1995,13 @@ impl Vm { if let Some(r) = self.promise_prototype { roots.push(r); } + // DOM wrapper identity cache: keep cached wrappers alive so that the + // same DOM node always returns the same JS object. + if let Some(bridge) = &self.dom_bridge { + for &wrapper_ref in bridge.node_wrappers.borrow().values() { + roots.push(wrapper_ref); + } + } roots }