@blueshed/railroad 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,3 +89,6 @@ loggedRequest(tag, handler): Handler // wrap route handler with access logging
89
89
  3. **No `text()` for attributes.** `text()` creates a DOM node. Use `computed()` for reactive attributes.
90
90
  4. **No JSX in effects without dispose scopes.** Any effect that rebuilds DOM must use `pushDisposeScope`/`popDisposeScope` and return a cleanup function. See `jsx.ts` source for the pattern.
91
91
  5. **No `transition-all` in CSS** near layout boundaries. Use specific properties.
92
+ 6. **No bare nested `when()`.** `when()` returns a fragment — nesting fragments inside another `when()` breaks dispose scope tracking. Always wrap an inner `when()` in a real element: `<div>{when(...)}</div>`.
93
+ 7. **No shared DOM nodes across `when()` branches.** Nodes must be created fresh inside each branch function. A node created outside and reused across branches will be torn out of the DOM when the other branch activates.
94
+ 8. **Guard against null inside `when()` branches.** Signal cascade order is not guaranteed — an inner `when()` can fire before the outer `when()` swaps it away. Always null-check even inside a branch that "shouldn't" be reached (e.g. `text(() => item.get()?.name ?? "")`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueshed/railroad",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Signals, JSX, and routes — a micro UI framework for Bun",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/signals.ts CHANGED
@@ -165,7 +165,19 @@ export function trackDispose(d: Dispose): void {
165
165
  // === computed() ===
166
166
 
167
167
  export function computed<T>(fn: () => T): Signal<T> {
168
- const s = new Signal<T>(fn());
168
+ // Suspend outer tracking during initial evaluation so computed()
169
+ // inside list() render functions doesn't leak subscriptions to the
170
+ // list effect's listener — which causes infinite sync re-entry.
171
+ const prevListener = currentListener;
172
+ const prevDeps = currentDeps;
173
+ currentListener = null;
174
+ currentDeps = null;
175
+ let initial: T;
176
+ try { initial = fn(); } finally {
177
+ currentListener = prevListener;
178
+ currentDeps = prevDeps;
179
+ }
180
+ const s = new Signal<T>(initial);
169
181
  const dispose = effect(() => s.set(fn()));
170
182
  trackDispose(dispose);
171
183
  return s;