You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Switch auto-targeting to use beam-id / beam-item-id (remove plain id auto-detection) and update docs/examples accordingly. Add normalizeHtmlForTarget to unwrap a single-server-root that matches the target's beam-id/beam-item-id to avoid nesting, and propagate that normalization into swap/append/prepend/replace/morph flows. Extend morph to accept a MorphStyle option (innerHTML|outerHTML) and use outerHTML when morphing deduped items. Update TypeScript types and README examples to reflect beam-id usage and clarify target resolution behavior.
<divid="content">Main content</div>, // Auto-detected by ID
276
+
<divbeam-id="content">Main content</div>, // Auto-detected by beam-id
275
277
],
276
278
{ target: '#header' } // Only first item gets explicit target
277
279
)
@@ -280,10 +282,15 @@ export function updateDashboard(ctx: BeamContext<Env>) {
280
282
281
283
**Target Resolution Order:**
282
284
1. Explicit target from comma-separated list (by index)
283
-
2.ID from the HTML fragment's root element (`id`, `beam-id`, or `beam-item-id`)
285
+
2.Identity from the HTML fragment's root element (`beam-id` or `beam-item-id`)
284
286
3. Frontend fallback (`beam-target` on the triggering element)
285
287
4. Skip if no target found
286
288
289
+
Notes:
290
+
-`beam-target` accepts any valid CSS selector (e.g. `#id`, `.class`, `[attr=value]`). Using `#id` targets is still fully supported.
291
+
- Auto-targeting (step 2) intentionally does **not** use plain `id="..."` anymore; it uses only `beam-id` / `beam-item-id`.
292
+
- When an explicit target is used and the server returns a single root element that has the same `beam-id`/`beam-item-id` as the target, Beam unwraps it and swaps only the target’s inner content. This prevents accidentally nesting the component inside itself.
293
+
287
294
**Exclusion:** Use `!selector` to explicitly skip an item:
0 commit comments