Skip to content
Snippets Groups Projects

Refactor trackViews() to reliably remove views

Merged Administrator requested to merge cleanup-code-views into master

Created by: lguychard

Fixes #4064

Refactors trackViews() to stop relying on a ViewResolver's selector to detect removed views. We now inspect removedNodes to see if any of the removed nodes is a known view, or contains one or more known views.

With this refactor, the viewStates logic is now encapsulated within trackViews(), which simply emits every added views as a ViewWithSubscriptions, and takes care of calling view.subscriptions.unsubscribe() when the view is removed from the page. This prevents the consumer from having to reimplement the viewStates pattern.

Test plan: The view addition/removal logic is well tested by existing unit tests, but performance should be benchmarked as view removal is now more expensive.

TODO:

  • Fix remaining failing test handleContentViews() › detects addition, mutation, and removal of content views
  • Consider consolidating code_views.test.ts with views.test.ts

Merge request reports

Approval is optional

Merged by avatar (Jun 20, 2025 1:12am UTC)

Merge details

  • Changes merged into master with 1b2ab67c.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading