|
@@ -734,6 +734,11 @@ class Component(BaseComponent, ABC):
|
|
children: The children of the component.
|
|
children: The children of the component.
|
|
|
|
|
|
"""
|
|
"""
|
|
|
|
+ from reflex.components.base.fragment import Fragment
|
|
|
|
+ from reflex.components.core.cond import Cond
|
|
|
|
+ from reflex.components.core.foreach import Foreach
|
|
|
|
+ from reflex.components.core.match import Match
|
|
|
|
+
|
|
no_valid_parents_defined = all(child._valid_parents == [] for child in children)
|
|
no_valid_parents_defined = all(child._valid_parents == [] for child in children)
|
|
if (
|
|
if (
|
|
not self._invalid_children
|
|
not self._invalid_children
|
|
@@ -743,21 +748,23 @@ class Component(BaseComponent, ABC):
|
|
return
|
|
return
|
|
|
|
|
|
comp_name = type(self).__name__
|
|
comp_name = type(self).__name__
|
|
- allowed_components = ["Fragment", "Foreach", "Cond", "Match"]
|
|
|
|
|
|
+ allowed_components = [
|
|
|
|
+ comp.__name__ for comp in (Fragment, Foreach, Cond, Match)
|
|
|
|
+ ]
|
|
|
|
|
|
def validate_child(child):
|
|
def validate_child(child):
|
|
child_name = type(child).__name__
|
|
child_name = type(child).__name__
|
|
|
|
|
|
# Iterate through the immediate children of fragment
|
|
# Iterate through the immediate children of fragment
|
|
- if child_name == "Fragment":
|
|
|
|
|
|
+ if isinstance(child, Fragment):
|
|
for c in child.children:
|
|
for c in child.children:
|
|
validate_child(c)
|
|
validate_child(c)
|
|
|
|
|
|
- if child_name == "Cond":
|
|
|
|
|
|
+ if isinstance(child, Cond):
|
|
validate_child(child.comp1)
|
|
validate_child(child.comp1)
|
|
validate_child(child.comp2)
|
|
validate_child(child.comp2)
|
|
|
|
|
|
- if child_name == "Match":
|
|
|
|
|
|
+ if isinstance(child, Match):
|
|
for cases in child.match_cases:
|
|
for cases in child.match_cases:
|
|
validate_child(cases[-1])
|
|
validate_child(cases[-1])
|
|
validate_child(child.default)
|
|
validate_child(child.default)
|