1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use *;
/// Inner storage for a dynamic node render closure.
///
/// Boxes a `dyn FnMut(&mut HookContext) -> VirtualNode` so it can be stored behind `Rc<UnsafeCell<>>`.
pub
/// Represents a text node in the virtual DOM.
///
/// Text nodes may optionally be bound to a reactive signal for automatic updates.
///
/// OPT 29: `content` is `Cow<'static, str>` instead of `String` so the
/// `html!` macro can emit `Cow::Borrowed("...")` for literal text
/// without allocating a `String` per text node per render. Runtime
/// text (signals, `format!`, `to_string()`) still falls through to
/// `Cow::Owned`. The renderer's `set_text_content` and
/// `create_text_node` calls take `&str`, which is what `Cow<'static, str>`
/// derefs to, so call sites use `.as_ref()` (yields `&str`).
/// A closure-based dynamic node that re-renders when its dependency signals change.
///
/// Holds a shared reference to a heap-allocated render closure that produces a fresh
/// `VirtualNode` on each evaluation. The renderer subscribes to the closure's
/// signals and patches the DOM automatically.
/// Contains a `HookContext` that persists hook state (like `use_signal`) across
/// re-renders, ensuring that signal values are not reset when the render function
/// is called again.
///
/// Uses `Rc<UnsafeCell<>>` instead of `Rc<RefCell<>>` to avoid runtime borrow
/// checking overhead. Safety is guaranteed by the single-threaded WASM context.
/// The `Rc` provides automatic memory management — the render closure is freed
/// when the last reference (either in the VirtualNode tree or the signal update
/// callback) is dropped.