From afea456335687b89d6d802897fd3bd39be815ba6 Mon Sep 17 00:00:00 2001 From: Marco 'Lubber' Wienkoop Date: Fri, 5 May 2023 13:52:55 +0200 Subject: [PATCH] fix(chore): encapsulate settimeout This PR encapsulates any setTimeout function. We had this almost everywhere except for the performance debugger and some other parts. Especially for the api module this removes potentionally code injection risk warnings from snyk. --- src/definitions/behaviors/api.js | 4 ++-- src/definitions/behaviors/form.js | 2 +- src/definitions/behaviors/state.js | 2 +- src/definitions/behaviors/visibility.js | 2 +- src/definitions/globals/site.js | 2 +- src/definitions/modules/accordion.js | 2 +- src/definitions/modules/calendar.js | 2 +- src/definitions/modules/checkbox.js | 2 +- src/definitions/modules/dimmer.js | 2 +- src/definitions/modules/dropdown.js | 8 ++++---- src/definitions/modules/embed.js | 2 +- src/definitions/modules/flyout.js | 2 +- src/definitions/modules/modal.js | 4 ++-- src/definitions/modules/nag.js | 4 ++-- src/definitions/modules/popup.js | 6 +++--- src/definitions/modules/progress.js | 2 +- src/definitions/modules/rating.js | 2 +- src/definitions/modules/search.js | 4 ++-- src/definitions/modules/shape.js | 2 +- src/definitions/modules/sidebar.js | 2 +- src/definitions/modules/slider.js | 2 +- src/definitions/modules/sticky.js | 2 +- src/definitions/modules/tab.js | 2 +- src/definitions/modules/toast.js | 2 +- src/definitions/modules/transition.js | 4 ++-- 25 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/definitions/behaviors/api.js b/src/definitions/behaviors/api.js index 105714752b..ad69069cf4 100644 --- a/src/definitions/behaviors/api.js +++ b/src/definitions/behaviors/api.js @@ -646,7 +646,7 @@ module.debug('Adding error state'); module.set.error(); if (module.should.removeError()) { - setTimeout(module.remove.error, settings.errorDuration); + setTimeout(function () { module.remove.error(); }, settings.errorDuration); } } module.debug('API Request failed', errorMessage, xhr); @@ -970,7 +970,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/behaviors/form.js b/src/definitions/behaviors/form.js index 4b63be9f37..5a990b1d8a 100644 --- a/src/definitions/behaviors/form.js +++ b/src/definitions/behaviors/form.js @@ -1494,7 +1494,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/behaviors/state.js b/src/definitions/behaviors/state.js index a633249f7d..dca08a1be0 100644 --- a/src/definitions/behaviors/state.js +++ b/src/definitions/behaviors/state.js @@ -482,7 +482,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/behaviors/visibility.js b/src/definitions/behaviors/visibility.js index 9028da1e8c..21252e1f67 100755 --- a/src/definitions/behaviors/visibility.js +++ b/src/definitions/behaviors/visibility.js @@ -1088,7 +1088,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/globals/site.js b/src/definitions/globals/site.js index 93e21f0ccd..fc84481cc0 100644 --- a/src/definitions/globals/site.js +++ b/src/definitions/globals/site.js @@ -292,7 +292,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/accordion.js b/src/definitions/modules/accordion.js index e5ca151d98..ce61a62270 100644 --- a/src/definitions/modules/accordion.js +++ b/src/definitions/modules/accordion.js @@ -438,7 +438,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/calendar.js b/src/definitions/modules/calendar.js index 6c2760628c..6a2c849f04 100644 --- a/src/definitions/modules/calendar.js +++ b/src/definitions/modules/calendar.js @@ -1479,7 +1479,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/checkbox.js b/src/definitions/modules/checkbox.js index a11129fb1f..cf08195d24 100644 --- a/src/definitions/modules/checkbox.js +++ b/src/definitions/modules/checkbox.js @@ -723,7 +723,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/dimmer.js b/src/definitions/modules/dimmer.js index ab0e1bb659..a350cf75fa 100755 --- a/src/definitions/modules/dimmer.js +++ b/src/definitions/modules/dimmer.js @@ -528,7 +528,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 5105636ac0..13d087be4e 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -1231,7 +1231,7 @@ module.set.filtered(); } clearTimeout(module.timer); - module.timer = setTimeout(module.search, settings.delay.search); + module.timer = setTimeout(function () { module.search(); }, settings.delay.search); }, label: { click: function (event) { @@ -3742,12 +3742,12 @@ show: function () { module.verbose('Delaying show event to ensure user intent'); clearTimeout(module.timer); - module.timer = setTimeout(module.show, settings.delay.show); + module.timer = setTimeout(function () { module.show(); }, settings.delay.show); }, hide: function () { module.verbose('Delaying hide event to ensure user intent'); clearTimeout(module.timer); - module.timer = setTimeout(module.hide, settings.delay.hide); + module.timer = setTimeout(function () { module.hide(); }, settings.delay.hide); }, }, @@ -3873,7 +3873,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/embed.js b/src/definitions/modules/embed.js index 73df0415aa..18d5438c57 100644 --- a/src/definitions/modules/embed.js +++ b/src/definitions/modules/embed.js @@ -440,7 +440,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/flyout.js b/src/definitions/modules/flyout.js index 337f078413..d3a99bb118 100644 --- a/src/definitions/modules/flyout.js +++ b/src/definitions/modules/flyout.js @@ -1247,7 +1247,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/modal.js b/src/definitions/modules/modal.js index 51f6f965a4..bc2ae995e3 100755 --- a/src/definitions/modules/modal.js +++ b/src/definitions/modules/modal.js @@ -527,7 +527,7 @@ }, debounce: function (method, delay) { clearTimeout(module.timer); - module.timer = setTimeout(method, delay); + module.timer = setTimeout(function () { method(); }, delay); }, keyboard: function (event) { var @@ -1273,7 +1273,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/nag.js b/src/definitions/modules/nag.js index 74d6bbc9be..ad77368cf2 100644 --- a/src/definitions/modules/nag.js +++ b/src/definitions/modules/nag.js @@ -88,7 +88,7 @@ } if (settings.displayTime > 0) { - setTimeout(module.hide, settings.displayTime); + setTimeout(function () { module.hide(); }, settings.displayTime); } module.show(); }, @@ -377,7 +377,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/popup.js b/src/definitions/modules/popup.js index 28892a7615..38aaac3dc8 100644 --- a/src/definitions/modules/popup.js +++ b/src/definitions/modules/popup.js @@ -194,7 +194,7 @@ ; clearTimeout(module.hideTimer); if (!openedWithTouch || (openedWithTouch && settings.addTouchEvents)) { - module.showTimer = setTimeout(module.show, delay); + module.showTimer = setTimeout(function () { module.show(); }, delay); } }, end: function () { @@ -204,7 +204,7 @@ : settings.delay ; clearTimeout(module.showTimer); - module.hideTimer = setTimeout(module.hide, delay); + module.hideTimer = setTimeout(function () { module.hide(); }, delay); }, touchstart: function (event) { openedWithTouch = true; @@ -1244,7 +1244,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/progress.js b/src/definitions/modules/progress.js index 28f958c09d..d03439b380 100644 --- a/src/definitions/modules/progress.js +++ b/src/definitions/modules/progress.js @@ -791,7 +791,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/rating.js b/src/definitions/modules/rating.js index 9aa88031e5..ebbb55f8a3 100644 --- a/src/definitions/modules/rating.js +++ b/src/definitions/modules/rating.js @@ -368,7 +368,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/search.js b/src/definitions/modules/search.js index 1f29fc1fb0..401f2e1382 100644 --- a/src/definitions/modules/search.js +++ b/src/definitions/modules/search.js @@ -169,7 +169,7 @@ callback = function () { module.cancel.query(); module.remove.focus(); - module.timer = setTimeout(module.hideResults, settings.hideDelay); + module.timer = setTimeout(function () { module.hideResults(); }, settings.hideDelay); } ; if (pageLostFocus) { @@ -1171,7 +1171,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/shape.js b/src/definitions/modules/shape.js index 8f2b5d93da..8a93d70d38 100644 --- a/src/definitions/modules/shape.js +++ b/src/definitions/modules/shape.js @@ -623,7 +623,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/sidebar.js b/src/definitions/modules/sidebar.js index 2a2ae07624..7ce9b07bed 100644 --- a/src/definitions/modules/sidebar.js +++ b/src/definitions/modules/sidebar.js @@ -898,7 +898,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/slider.js b/src/definitions/modules/slider.js index 467e2118bb..1a212ec200 100644 --- a/src/definitions/modules/slider.js +++ b/src/definitions/modules/slider.js @@ -1262,7 +1262,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/sticky.js b/src/definitions/modules/sticky.js index d8399abda6..bb2378b037 100755 --- a/src/definitions/modules/sticky.js +++ b/src/definitions/modules/sticky.js @@ -746,7 +746,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 0); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 0); }, display: function () { var diff --git a/src/definitions/modules/tab.js b/src/definitions/modules/tab.js index 478c7847e0..ed37fce47f 100644 --- a/src/definitions/modules/tab.js +++ b/src/definitions/modules/tab.js @@ -786,7 +786,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/toast.js b/src/definitions/modules/toast.js index 81ecb2973a..6577dbdd1e 100644 --- a/src/definitions/modules/toast.js +++ b/src/definitions/modules/toast.js @@ -702,7 +702,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var diff --git a/src/definitions/modules/transition.js b/src/definitions/modules/transition.js index bcd7cfbe48..50e9b4cacd 100644 --- a/src/definitions/modules/transition.js +++ b/src/definitions/modules/transition.js @@ -142,7 +142,7 @@ ? ($allModules.length - index) * interval : index * interval; module.debug('Delaying animation by', delay); - setTimeout(module.animate, delay); + setTimeout(function () { module.animate(); }, delay); }, animate: function (overrideSettings) { @@ -849,7 +849,7 @@ }); } clearTimeout(module.performance.timer); - module.performance.timer = setTimeout(module.performance.display, 500); + module.performance.timer = setTimeout(function () { module.performance.display(); }, 500); }, display: function () { var