Skip to content

Commit

Permalink
fix(chore): encapsulate settimeout
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lubber-de authored May 5, 2023
1 parent f840753 commit afea456
Show file tree
Hide file tree
Showing 25 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/definitions/behaviors/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/behaviors/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/behaviors/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/behaviors/visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/globals/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/dimmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
},
},

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/definitions/modules/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/definitions/modules/nag.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
}

if (settings.displayTime > 0) {
setTimeout(module.hide, settings.displayTime);
setTimeout(function () { module.hide(); }, settings.displayTime);
}
module.show();
},
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/definitions/modules/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/definitions/modules/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/sticky.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/definitions/modules/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit afea456

Please sign in to comment.