Available since v0.1.0

fs-assert-removed

Stable

Resolves when an element matching the selector is removed from the DOM after the trigger fires. Mutation-observed.

Syntax

fs-assert-removed="<selector>"

When to use it

  • Deleting items from a list (todos, cart, notifications)
  • Closing a modal whose content is unmounted (not just hidden)
  • Dismissing a toast by removal
  • Cleanup flows where an element should be torn down

If the element stays in the DOM but is hidden (display:none, visibility:hidden), use hidden instead.

Example

<button
  fs-assert="todos/remove-item"
  fs-trigger="click"
  fs-assert-removed=".todo-item">
  Delete
</button>

Passes when a matching .todo-item is removed from the DOM after the click.

Pre-existing matches matter

Unlike added, removed naturally depends on a pre-existing match — you can't remove what isn't there. The assertion watches the removedElements mutation list and resolves when an element matching the selector is removed.

Pairs well with

Gotchas

  • Using removed when hidden is correct. If your modal uses display: none rather than unmounting, the element is still in the DOM. Use hidden.
  • Batched removals. A single click may remove many elements in the same microtask. removed resolves as soon as ANY matching element is removed — use [count=N] for cardinality checks at the removal moment (but note count is evaluated on the current DOM, not the removed set).

See also