Fix event bubbling inside templates after a hot template reload (#2484)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-06-06 17:10:38 -07:00
1 parent b6cdcb4e7f
commit 5494e38cf8
4 files changed
+101 -68

No files matched your search

+18 -2
View File
@@ -80,11 +80,27 @@ impl VirtualDom {
}
impl ElementPath {
pub(crate) fn is_decendant(&self, small: &&[u8]) -> bool {
small.len() <= self.path.len() && *small == &self.path[..small.len()]
pub(crate) fn is_decendant(&self, small: &[u8]) -> bool {
small.len() <= self.path.len() && small == &self.path[..small.len()]
}
}
#[test]
fn is_decendant() {
let event_path = ElementPath {
path: &[1, 2, 3, 4, 5],
};
assert!(event_path.is_decendant(&[1, 2, 3, 4, 5]));
assert!(event_path.is_decendant(&[1, 2, 3, 4]));
assert!(event_path.is_decendant(&[1, 2, 3]));
assert!(event_path.is_decendant(&[1, 2]));
assert!(event_path.is_decendant(&[1]));
assert!(!event_path.is_decendant(&[1, 2, 3, 4, 5, 6]));
assert!(!event_path.is_decendant(&[2, 3, 4]));
}
impl PartialEq<&[u8]> for ElementPath {
fn eq(&self, other: &&[u8]) -> bool {
self.path.eq(*other)