diff options
author | chickenleaf <lashwinib@gmail.com> | 2024-10-26 21:48:00 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-26 16:18:00 +0000 |
commit | 53911f4e5a5ec50dae73a5d4d36a80637e267fee (patch) | |
tree | a8910bb14ee410ab1348f4ca9c32bf5208e1ed04 /components/script/dom | |
parent | 82c9d413306239a96b5f4ca8fc2612fd55cee501 (diff) | |
download | servo-53911f4e5a5ec50dae73a5d4d36a80637e267fee.tar.gz servo-53911f4e5a5ec50dae73a5d4d36a80637e267fee.zip |
GC hazard fix in customelementregistry.rs (#34019)
* GC hazard fix in customelement.registry.rs
Signed-off-by: L Ashwin B <lashwinib@gmail.com>
* removed redundant borrow
Signed-off-by: L Ashwin B <lashwinib@gmail.com>
---------
Signed-off-by: L Ashwin B <lashwinib@gmail.com>
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/customelementregistry.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index 2cded8715b3..dfbbe5e5d79 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -598,13 +598,11 @@ impl CustomElementRegistryMethods for CustomElementRegistry { } } - // Step 3 - let mut map = self.when_defined.borrow_mut(); - - // Steps 4, 5 - let promise = map.get(&name).cloned().unwrap_or_else(|| { + // Steps 3, 4, 5 + let existing_promise = self.when_defined.borrow().get(&name).cloned(); + let promise = existing_promise.unwrap_or_else(|| { let promise = Promise::new_in_current_realm(comp, can_gc); - map.insert(name, promise.clone()); + self.when_defined.borrow_mut().insert(name, promise.clone()); promise }); |