Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent firing callbacks until members are destroyed #366

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/blaze/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,19 @@ Blaze._destroyView = function (view, _skipNodes) {
return;
view.isDestroyed = true;

Blaze._fireCallbacks(view, 'destroyed');

// Destroy views and elements recursively. If _skipNodes,
// only recurse up to views, not elements, for the case where
// the backend (jQuery) is recursing over the elements already.

if (view._domrange)
view._domrange.destroyMembers(_skipNodes);
if (view._domrange) view._domrange.destroyMembers(_skipNodes);

// XXX: fire callbacks after potential members are destroyed
// otherwise it's tracker.flush will cause the above line will
// not be called and their views won't be destroyed
// Involved issues: DOMRange "Must be attached" error, mem leak

Blaze._fireCallbacks(view, 'destroyed');
};

Blaze._destroyNode = function (node) {
Expand Down