Skip to content

Commit

Permalink
fix: symbol should be check in the diff as well
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanceras committed Apr 16, 2024
1 parent 0334516 commit cf5369c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
24 changes: 17 additions & 7 deletions crates/core/src/dom/dom_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,33 @@ impl DomNode {
}
}

pub(crate) fn is_fragment(&self) -> bool {
/// returns true if this an element node
pub fn is_element(&self) -> bool {
matches!(&self.inner, DomInner::Element{..})
}

/// returns true if this a fragment node
pub fn is_fragment(&self) -> bool {
matches!(&self.inner, DomInner::Fragment { .. })
}

pub(crate) fn is_text_node(&self) -> bool {
/// returns true if this a text node
pub fn is_text_node(&self) -> bool {
matches!(&self.inner, DomInner::Text(_))
}

pub(crate) fn is_comment(&self) -> bool {
/// returns true if this Comment node
pub fn is_comment(&self) -> bool {
matches!(&self.inner, DomInner::Comment(_))
}

pub(crate) fn is_symbol(&self) -> bool {
/// returns true if this DomNode is a html entity symbol
pub fn is_symbol(&self) -> bool {
matches!(&self.inner, DomInner::Symbol(_))
}

#[allow(unused)]
pub(crate) fn is_stateful_component(&self) -> bool {
/// returns true if this is a stateful component
pub fn is_stateful_component(&self) -> bool {
matches!(&self.inner, DomInner::StatefulComponent { .. })
}

Expand All @@ -204,6 +213,7 @@ impl DomNode {
}

/// exposed the underlying wrapped node as `web_sys::Element`
#[track_caller]
pub fn as_element(&self) -> web_sys::Element {
match &self.inner {
DomInner::Element { element, .. } => element.clone(),
Expand Down Expand Up @@ -537,7 +547,7 @@ impl DomNode {
//TODO: check if the element has a dispatch mount event
//otherwise dont dispatch the mount event
fn dispatch_mount_event(&self) {
if !self.is_text_node() && !self.is_comment() && !self.is_symbol(){
if self.is_element() || self.is_stateful_component(){
let event_target: web_sys::EventTarget = self.as_element().unchecked_into();
event_target
.dispatch_event(&MountEvent::create_web_event())
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/vdom/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ pub fn diff_recursive<'a, MSG>(
(Node::Leaf(old_leaf), Node::Leaf(new_leaf)) => {
match (old_leaf, new_leaf) {
(Leaf::Text(_), Leaf::Text(_))
| (Leaf::Symbol(_), Leaf::Symbol(_))
| (Leaf::Comment(_), Leaf::Comment(_))
| (Leaf::DocType(_), Leaf::DocType(_)) => {
if old_leaf != new_leaf {
Expand Down

0 comments on commit cf5369c

Please sign in to comment.