From 6ccd2c831643ae2c50dca813c90b30668e2f9cf5 Mon Sep 17 00:00:00 2001 From: Taras Romaniv Date: Thu, 21 Sep 2017 11:32:21 -0700 Subject: [PATCH] fix memory leak in a "flat" mode Event listeners (bound to the document and window) were not cleaned after hiding in a "flat" mode. --- spectrum.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spectrum.js b/spectrum.js index e129e184..6183f9cc 100644 --- a/spectrum.js +++ b/spectrum.js @@ -668,13 +668,13 @@ } function hide() { - // Return if hiding is unnecessary - if (!visible || flat) { return; } - visible = false; - $(doc).off("keydown.spectrum", onkeydown); $(doc).off("click.spectrum", clickout); $(window).off("resize.spectrum", resize); + + // Return if hiding is unnecessary + if (!visible || flat) { return; } + visible = false; replacer.removeClass("sp-active"); container.addClass("sp-hidden");