The entire day in calendar is now clickable when a day need to be selected

This commit is contained in:
Greg Burri 2025-05-31 21:49:07 +02:00
parent 4c6f39b61f
commit f228486c5a
3 changed files with 54 additions and 39 deletions

View file

@ -14,6 +14,10 @@ pub trait SelectorExt {
where
T: JsCast;
fn selector_upwards<T>(&self, selector: &str) -> Option<T>
where
T: JsCast;
fn deep_clone(&self) -> Self;
}
@ -41,6 +45,25 @@ impl SelectorExt for Element {
.collect()
}
fn selector_upwards<T>(&self, selector: &str) -> Option<T>
where
T: JsCast,
{
let mut current = self.clone();
// while let Some(parent) = current.parent_element() {
loop {
if let Ok(true) = current.matches(selector) {
return Some(current.dyn_into::<T>().unwrap());
}
if let Some(parent) = current.parent_element() {
current = parent;
} else {
return None;
}
}
}
fn deep_clone(&self) -> Self {
self.clone_node_with_deep(true)
.unwrap()