Timer: make the interval property mandatory

A default of 0 is not a great default because that's way too often
This commit is contained in:
Olivier Goffart 2024-09-17 17:45:02 +02:00
parent 3f3ac7e347
commit bcdc3e1cee
3 changed files with 17 additions and 1 deletions

View file

@ -42,6 +42,14 @@ fn lower_timer(
return;
}
if !timer_element.borrow().is_binding_set("interval", true) {
diag.push_error(
"Timer must have a binding set for its 'interval' property".into(),
&*timer_element.borrow(),
);
return;
}
// Remove the timer_element from its parent
let old_size = parent_element.borrow().children.len();
parent_element.borrow_mut().children.retain(|child| !Rc::ptr_eq(child, timer_element));

View file

@ -11,4 +11,12 @@ export component Def {
// ^error{Timer cannot be directly repeated or conditional}
if false: Abc {}
Timer {
// ^error{Timer must have a binding set for its 'interval' property}
running: false;
}
Timer {}
// ^error{Timer must have a binding set for its 'interval' property}
}