From 50b009a61e3d3f7bd3eefd74dfffe7448f42fbda Mon Sep 17 00:00:00 2001 From: Steve Brudz Date: Fri, 24 Apr 2020 11:22:12 -0500 Subject: [PATCH] Extract debounce time into a constant --- spec/JustNotSorrySpec.js | 2 +- src/JustNotSorry.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/JustNotSorrySpec.js b/spec/JustNotSorrySpec.js index 8c825c8..7d16145 100644 --- a/spec/JustNotSorrySpec.js +++ b/spec/JustNotSorrySpec.js @@ -182,7 +182,7 @@ describe('JustNotSorry', function () { expect(warningChecker.addWarnings).toHaveBeenCalledTimes(1); expect(warningChecker.addWarnings).toHaveBeenCalledWith(target.parentNode); done(); - }, 510); + }, WAIT_TIME_BEFORE_RECALC_WARNINGS + 10); }); }); }); diff --git a/src/JustNotSorry.js b/src/JustNotSorry.js index 54aefc9..88d637e 100644 --- a/src/JustNotSorry.js +++ b/src/JustNotSorry.js @@ -2,6 +2,7 @@ var warningChecker = new WarningChecker(WARNINGS); var editableDivCount = 0; +var WAIT_TIME_BEFORE_RECALC_WARNINGS = 500; // from underscore.js // Returns a function, that, as long as it continues to be invoked, will not @@ -57,7 +58,7 @@ var removeObserver = function() { var checkForWarnings = debounce(function() { warningChecker.removeWarnings(this.parentNode); warningChecker.addWarnings(this.parentNode); -}, 500); +}, WAIT_TIME_BEFORE_RECALC_WARNINGS); var applyEventListeners = function(id) { var targetDiv = document.getElementById(id);