Files
ritz/ritz
Aaron SinclairandClaude 7efa7786cf Fix conditional branch rendering: append children to wrapper
**Bug:** Conditional branches (match/case) rendered empty content.
- Tabs would switch but show no content in each tab
- Wrapper div was created but children never appended to it

**Root Cause:**
In `_emit_conditional_branch_function`, statements were rendered but
their return values were discarded:
```python
for stmt in body:
    self._emit_statement(stmt)  # ← return value ignored!
```

**Fix:**
Append returned elements to wrapper, just like `_emit_with` does:
```python
for stmt in body:
    child_var = self._emit_statement(stmt)
    if child_var:
        self.lines.append(f"call void @js_append_child(i32 %{wrapper_var}, i32 %{child_var})")
```

**LLVM Before:**
```llvm
%var87 = call i32 @js_create_element(...)  ; wrapper
%var89 = call i32 @js_create_element(...)  ; content
; ... build var89's children ...
ret i32 %var87  ; ← var89 never appended!
```

**LLVM After:**
```llvm
%var87 = call i32 @js_create_element(...)  ; wrapper
%var89 = call i32 @js_create_element(...)  ; content
; ... build var89's children ...
call void @js_append_child(i32 %var87, i32 %var89)  ; ← FIX!
ret i32 %var87
```

**Result:**
✅ Tabs example now shows content in each tab
✅ Vertical tabs (nested conditionals) also work

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 15:05:10 -08:00
..