From 83590161bd9ab6a25c7d196a86c2a287ba488392 Mon Sep 17 00:00:00 2001 From: jacobdoran Date: Thu, 28 Jan 2021 13:44:48 +0000 Subject: [PATCH] Fixed event listener memory leak Event listeners should be removed when plugin is destroyed. --- src/plugins/cursor-plugin.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/cursor-plugin.js b/src/plugins/cursor-plugin.js index 1ca9603..ce7bb39 100644 --- a/src/plugins/cursor-plugin.js +++ b/src/plugins/cursor-plugin.js @@ -135,6 +135,8 @@ export const yCursorPlugin = (awareness, { cursorBuilder = defaultCursorBuilder, return { update: updateCursorInfo, destroy: () => { + view.dom.removeEventListener('focusin', updateCursorInfo) + view.dom.removeEventListener('focusout', updateCursorInfo) awareness.off('change', awarenessListener) awareness.setLocalStateField(cursorStateField, null) }