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.
Fixes #61
At the moment, the
ResizeObserver
causes a memory leak, because wenever unobserve the Quill container, which then keeps a reference to
that node in memory (even if the node is disconnected from the DOM).
This change tweaks our
ResizeObserver
callback to check if the Quillcontainer is still connected to the DOM. If not, we unobserve, which
allows the
ResizeObserver
and DOM node to both be correctly garbage-collected.
However, we can't just leave it there, because consumers may potentially
disconnect their Quill instance, and then reconnect it to the DOM. In
order to address this edge case, we re-register the
ResizeObserver
whenever an update is made to a cursor, which should start listening
correctly the next time any cursor is updated.
Note that there's still a corner case:
ResizeObserver
stops observingResizeObserver
hasn'tbeen re-registered
However, this case should be pretty unusual, and is hard to remedy
without even more observers, so let's leave it there. Consumers can
manually fire
cursors.update()
when reconnecting Quill to the DOM tocorrectly re-register the
ResizeObserver
.