diff --git a/packages/native-core/src/node_ref.rs b/packages/native-core/src/node_ref.rs index 3816dd77a..b1e1b5e1d 100644 --- a/packages/native-core/src/node_ref.rs +++ b/packages/native-core/src/node_ref.rs @@ -49,6 +49,10 @@ impl<'a> NodeView<'a> { .flatten() } + pub fn listeners(&self) -> &'a [Listener<'a>] { + self.el().map(|el| el.listeners).unwrap_or_default() + } + fn el(&self) -> Option<&'a VElement<'a>> { if let VNode::Element(el) = &self.inner { Some(el) @@ -178,6 +182,7 @@ pub struct NodeMask { tag: bool, namespace: bool, text: bool, + listeners: bool, } impl NodeMask { @@ -191,6 +196,7 @@ impl NodeMask { || (self.namespace && other.namespace) || self.attritutes.overlaps(&other.attritutes) || (self.text && other.text) + || (self.listeners && other.listeners) } pub fn union(&self, other: &Self) -> Self { @@ -199,6 +205,7 @@ impl NodeMask { tag: self.tag | other.tag, namespace: self.namespace | other.namespace, text: self.text | other.text, + listeners: self.listeners | other.listeners, } } @@ -208,6 +215,7 @@ impl NodeMask { tag: false, namespace: false, text: false, + listeners: false, } } @@ -233,4 +241,9 @@ impl NodeMask { self.text = true; self } + + pub const fn with_listeners(mut self) -> Self { + self.listeners = true; + self + } } diff --git a/packages/native-core/src/real_dom.rs b/packages/native-core/src/real_dom.rs index b43327713..4d6964572 100644 --- a/packages/native-core/src/real_dom.rs +++ b/packages/native-core/src/real_dom.rs @@ -152,6 +152,7 @@ impl RealDom { scope: _, root, } => { + nodes_updated.push((root as usize, NodeMask::new().with_listeners())); if let Some(v) = self.nodes_listening.get_mut(event_name) { v.insert(root as usize); } else { @@ -161,6 +162,7 @@ impl RealDom { } } RemoveEventListener { root, event } => { + nodes_updated.push((root as usize, NodeMask::new().with_listeners())); let v = self.nodes_listening.get_mut(event).unwrap(); v.remove(&(root as usize)); }