From 33f67e4c0fe817fcc066f2779e19de11077fad7d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 9 Sep 2021 01:06:01 +0200 Subject: [PATCH] LibWeb: Use the task queue to fire "load" and "error" events on images --- Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 039e58f3e7f..e34442cea54 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -22,13 +22,17 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, QualifiedName qualif { m_image_loader.on_load = [this] { this->document().update_layout(); - dispatch_event(DOM::Event::create(EventNames::load)); + queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] { + dispatch_event(DOM::Event::create(EventNames::load)); + }); }; m_image_loader.on_fail = [this] { dbgln("HTMLImageElement: Resource did fail: {}", src()); this->document().update_layout(); - dispatch_event(DOM::Event::create(EventNames::error)); + queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] { + dispatch_event(DOM::Event::create(EventNames::error)); + }); }; m_image_loader.on_animate = [this] {