mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
New syntax: Only allow children if the component has @children
For compatibility reason, this is also allowed when inheriting
This commit is contained in:
parent
64b248cfa9
commit
84ae4d2928
2 changed files with 19 additions and 7 deletions
|
@ -467,12 +467,13 @@ impl ElementType {
|
|||
tr: &TypeRegister,
|
||||
) -> Result<ElementType, String> {
|
||||
match self {
|
||||
Self::Component(component) => {
|
||||
return component
|
||||
.root_element
|
||||
.borrow()
|
||||
.base_type
|
||||
.lookup_type_for_child_element(name, tr)
|
||||
Self::Component(component) if component.child_insertion_point.borrow().is_none() => {
|
||||
let base_type = component.root_element.borrow().base_type.clone();
|
||||
if base_type == tr.empty_type() {
|
||||
return Err(format!("'{}' cannot have children. Only components with @children can have children", component.id));
|
||||
} else {
|
||||
return base_type.lookup_type_for_child_element(name, tr);
|
||||
}
|
||||
}
|
||||
Self::Builtin(builtin) => {
|
||||
if let Some(child_type) = builtin.additional_accepted_child_types.get(name) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue