#6936: call remove on every object on canvas.clear #6937
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Suggested fix for #6936: calls canvas.remove on every canvas object, instead of only clearing the canvas._objects array (this would result in firing additional removal events and removing the canvas property of the objects previously added to the canvas).
I understand we should be careful if the initial implementation may have skipped this removal on purpose. In terms of performance, I don't think removal itself is particularly costly in any way. Calling canvas.remove will fire 'object:removed' on canvas and 'removed' on each object for every object, the listeners may be costly or unwanted in some way.
If this is a cause of concern, either because it may be a performance issue or because it may be considered a breaking change: we could maybe implement an option parameter to canvas.remove, maybe called "suppressObjectRemoveEvents", that would default to true - so that this new behavior would be opt-in (at least temporarily).