LibWeb: Fire slotchange events when a slot is changed

This commit is contained in:
Shannon Booth 2025-03-08 16:03:54 +13:00 committed by Tim Flynn
commit b543523717
Notes: github-actions[bot] 2025-03-10 18:38:25 +00:00
7 changed files with 717 additions and 5 deletions

View file

@ -28,6 +28,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/CustomElements/CustomElementDefinition.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/HTMLSlotElement.h>
#include <LibWeb/HTML/Location.h>
#include <LibWeb/HTML/PromiseRejectionEvent.h>
#include <LibWeb/HTML/Scripting/Agent.h>
@ -677,9 +678,9 @@ void queue_mutation_observer_microtask(DOM::Document const& document)
for (auto& observer : surrounding_agent.mutation_observers)
notify_set.append(&observer);
// FIXME: 3. Let signalSet be a clone of the surrounding agents signal slots.
// FIXME: 4. Empty the surrounding agents signal slots.
// 3. Let signalSet be a clone of the surrounding agents signal slots.
// 4. Empty the surrounding agents signal slots.
auto signal_set = move(surrounding_agent.signal_slots);
// 5. For each mo of notifySet:
for (auto& mutation_observer : notify_set) {
@ -716,7 +717,12 @@ void queue_mutation_observer_microtask(DOM::Document const& document)
}
}
// FIXME: 6. For each slot of signalSet, fire an event named slotchange, with its bubbles attribute set to true, at slot.
// 6. For each slot of signalSet, fire an event named slotchange, with its bubbles attribute set to true, at slot.
for (auto& slot : signal_set) {
DOM::EventInit event_init;
event_init.bubbles = true;
slot->dispatch_event(DOM::Event::create(slot->realm(), HTML::EventNames::slotchange, event_init));
}
}));
}