mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-24 23:23:58 +00:00
LibWeb: Set window object as this value in set{Interval,Timeout}()
This commit is contained in:
parent
7defc521be
commit
14dffe4721
Notes:
sideshowbarker
2024-07-19 06:17:06 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/14dffe47218 Pull-request: https://github.com/SerenityOS/serenity/pull/2319
1 changed files with 4 additions and 2 deletions
|
@ -68,7 +68,8 @@ void Window::set_interval(JS::Function& callback, i32 interval)
|
|||
(void)Core::Timer::construct(interval, [handle = make_handle(&callback)] {
|
||||
auto& function = const_cast<JS::Function&>(static_cast<const JS::Function&>(*handle.cell()));
|
||||
auto& interpreter = function.interpreter();
|
||||
interpreter.call(function);
|
||||
auto& window = static_cast<Bindings::WindowObject&>(interpreter.global_object());
|
||||
interpreter.call(function, &window);
|
||||
}).leak_ref();
|
||||
}
|
||||
|
||||
|
@ -78,7 +79,8 @@ void Window::set_timeout(JS::Function& callback, i32 interval)
|
|||
auto& timer = Core::Timer::construct(interval, [handle = make_handle(&callback)] {
|
||||
auto& function = const_cast<JS::Function&>(static_cast<const JS::Function&>(*handle.cell()));
|
||||
auto& interpreter = function.interpreter();
|
||||
interpreter.call(function);
|
||||
auto& window = static_cast<Bindings::WindowObject&>(interpreter.global_object());
|
||||
interpreter.call(function, &window);
|
||||
}).leak_ref();
|
||||
timer.set_single_shot(true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue