diff --git a/boa_engine/src/context/mod.rs b/boa_engine/src/context/mod.rs index 4f8ef59c9d5..96b9e06ddd0 100644 --- a/boa_engine/src/context/mod.rs +++ b/boa_engine/src/context/mod.rs @@ -717,13 +717,11 @@ impl Context<'_> { // 1. If the execution context stack is empty, return null. // 2. Let ec be the topmost execution context on the execution context stack whose ScriptOrModule component is not null. // 3. If no such execution context exists, return null. Otherwise, return ec's ScriptOrModule. - for frame in self.vm.frames.iter().rev() { - if frame.active_runnable.is_some() { - return frame.active_runnable.clone(); - } - } - - None + self.vm + .frames + .iter() + .rev() + .find_map(|frame| frame.active_runnable.clone()) } /// Get `active function object`