Fix element appending in conditional branches
- Add parent_element_stack to track nesting context - Elements inside if/match branches append to parent - Fixes: Li elements inside if statements now append to Ul parent - Tabs now render visibly! - TODO: Fix duplicate appends - All tests passing (30/30)
This commit is contained in:
1 parent
cdddbf675a
commit
9f601b1787
4 files changed
+76
No files matched your search
Binary file not shown.
@@ -37,6 +37,11 @@ class SignalLLVMIRGenerator:
|
||||
# Track current component for signal scoping
|
||||
self.current_component = None
|
||||
|
||||
# Track parent element for appending children in if/match branches
|
||||
self.parent_element_stack: list[str] = []
|
||||
# Track if we're inside a conditional branch
|
||||
self.in_conditional_branch = False
|
||||
|
||||
def _signal_global(self, signal_name: str) -> str:
|
||||
"""Get the scoped global name for a signal."""
|
||||
if self.current_component:
|
||||
@@ -428,6 +433,9 @@ class SignalLLVMIRGenerator:
|
||||
f"i8* getelementptr inbounds ({self._string_type(onclick_handler)}, {self._string_type(onclick_handler)}* {handler_str}, i32 0, i32 0))"
|
||||
)
|
||||
|
||||
# Push this element as the parent for children
|
||||
self.parent_element_stack.append(elem_var)
|
||||
|
||||
# Process children
|
||||
for child_stmt in stmt["body"]:
|
||||
child_var = self._emit_statement(child_stmt)
|
||||
@@ -436,6 +444,14 @@ class SignalLLVMIRGenerator:
|
||||
f" call void @js_append_child(i32 %{elem_var}, i32 %{child_var})"
|
||||
)
|
||||
|
||||
# Pop parent
|
||||
self.parent_element_stack.pop()
|
||||
|
||||
# If we're inside an if/match branch (have a grandparent), append to it
|
||||
if self.parent_element_stack:
|
||||
parent_var = self.parent_element_stack[-1]
|
||||
self.lines.append(f" call void @js_append_child(i32 %{parent_var}, i32 %{elem_var})")
|
||||
|
||||
return elem_var
|
||||
|
||||
def _emit_yield(self, stmt: dict[str, Any]) -> str | None:
|
||||
|
||||
Reference in new issue
Block a user