Hi,
This problem only happens when you explicitly call Blaze.remove(view), but this piece of code causes the DOM to be destroyed before calling the onDestroyed callback.
|
if (range.attached && ! range.parentRange) |
|
range.detach(); |
|
range.destroy(); |
The way it should work (and how it works when a view is destroyed by any other means) is the DOM is destroyed after the onDestroyed callback is called.
The solution, as far as I can tell, is to simply reverse the order of range.detach() and range.destroy().
range.destroy();
if (range.attached && ! range.parentRange)
range.detach();
In my testing, this fixes the problem.
Note that this problem only applies to explicit calls to Blaze.remove(view). Destroying by other means all appears to work correctly.
Related
This problem, however, also seems to appear in the blaze-hot package.
|
view._domrange.detach(); |
|
view._domrange.destroy(); |
This problem occurs when updating the JS code of a template. When a hot module reload is performed on the template, the onDestroyed callback is called, but if it tries to reference the DOM, it will throw an error.
The solution is the same as the above, to switch the order of detach() and destroy(). When that is changed, the problem is fixed.
Let me know if this is not the right place to post the issue about blaze-hot.
Thank you!
Hi,
This problem only happens when you explicitly call
Blaze.remove(view), but this piece of code causes the DOM to be destroyed before calling theonDestroyedcallback.blaze/packages/blaze/view.js
Lines 695 to 697 in a8dab83
The way it should work (and how it works when a view is destroyed by any other means) is the DOM is destroyed after the
onDestroyedcallback is called.The solution, as far as I can tell, is to simply reverse the order of
range.detach()andrange.destroy().In my testing, this fixes the problem.
Note that this problem only applies to explicit calls to
Blaze.remove(view). Destroying by other means all appears to work correctly.Related
This problem, however, also seems to appear in the
blaze-hotpackage.blaze/packages/blaze-hot/update-templates.js
Lines 132 to 133 in a8dab83
This problem occurs when updating the JS code of a template. When a hot module reload is performed on the template, the
onDestroyedcallback is called, but if it tries to reference the DOM, it will throw an error.The solution is the same as the above, to switch the order of
detach()anddestroy(). When that is changed, the problem is fixed.Let me know if this is not the right place to post the issue about
blaze-hot.Thank you!