瀏覽代碼

LibWeb: Fire the `change` event synchronously when committing changes

The spec does not say to do this asynchronously on a task queue.
Timothy Flynn 1 年之前
父節點
當前提交
301d58e2d9
共有 2 個文件被更改,包括 3 次插入6 次删除
  1. 1 2
      Tests/LibWeb/Text/input/input-commit.html
  2. 2 4
      Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp

+ 1 - 2
Tests/LibWeb/Text/input/input-commit.html

@@ -1,12 +1,11 @@
 <input id=input type=text>
 <script src="include.js"></script>
 <script>
-    asyncTest((done) => {
+    test(() => {
         let input = document.getElementById("input");
 
         input.addEventListener("change", () => {
             println(input.value);
-            done();
         });
 
         internals.sendText(input, "wfh :^)");

+ 2 - 4
Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp

@@ -433,10 +433,8 @@ void HTMLInputElement::commit_pending_changes()
 
     m_has_uncommitted_changes = false;
 
-    queue_an_element_task(HTML::Task::Source::UserInteraction, [this] {
-        auto change_event = DOM::Event::create(realm(), HTML::EventNames::change, { .bubbles = true });
-        dispatch_event(change_event);
-    });
+    auto change_event = DOM::Event::create(realm(), HTML::EventNames::change, { .bubbles = true });
+    dispatch_event(change_event);
 }
 
 void HTMLInputElement::update_placeholder_visibility()