mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Fire slot change events when the slot content changes (#35137)
* Add the onslotchange attribute to ShadowRoot Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add spec comments to MutationObserver::queue_mutation_observer_microtask Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add DomRefCell::take Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Add spec comments to notify_mutation_observers Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Fire slotchange events when a slot changes Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * ./mach fmt Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Fix check for when to dispatch slot events Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Potentially fire slot change events in Node::remove Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * ./mach fmt Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Bump stylo Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Move "signal a slot change" into ScriptThread impl Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
cd93841ba1
commit
859cc6ab9b
17 changed files with 152 additions and 119 deletions
|
@ -32,6 +32,7 @@ use crate::dom::node::{Node, ShadowIncluding};
|
|||
use crate::dom::text::Text;
|
||||
use crate::dom::virtualmethods::VirtualMethods;
|
||||
use crate::script_runtime::CanGc;
|
||||
use crate::ScriptThread;
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#the-slot-element>
|
||||
#[dom_struct]
|
||||
|
@ -185,6 +186,10 @@ impl HTMLSlotElement {
|
|||
)
|
||||
}
|
||||
|
||||
pub(crate) fn has_assigned_nodes(&self) -> bool {
|
||||
!self.assigned_nodes.borrow().is_empty()
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#find-flattened-slotables>
|
||||
fn find_flattened_slottables(&self, result: &mut RootedVec<Slottable>) {
|
||||
// Step 1. Let result be an empty list.
|
||||
|
@ -312,8 +317,12 @@ impl HTMLSlotElement {
|
|||
rooted_vec!(let mut slottables);
|
||||
self.find_slottables(&mut slottables);
|
||||
|
||||
// Step 2. TODO If slottables and slot’s assigned nodes are not identical,
|
||||
// Step 2. If slottables and slot’s assigned nodes are not identical,
|
||||
// then run signal a slot change for slot.
|
||||
let slots_are_identical = self.assigned_nodes.borrow().iter().eq(slottables.iter());
|
||||
if !slots_are_identical {
|
||||
ScriptThread::signal_a_slot_change(self);
|
||||
}
|
||||
|
||||
// Step 3. Set slot’s assigned nodes to slottables.
|
||||
*self.assigned_nodes.borrow_mut() = slottables.iter().cloned().collect();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue