Skip to content

Commit afea456

Browse files
authored
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.
1 parent f840753 commit afea456

25 files changed

+35
-35
lines changed

src/definitions/behaviors/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@
646646
module.debug('Adding error state');
647647
module.set.error();
648648
if (module.should.removeError()) {
649-
setTimeout(module.remove.error, settings.errorDuration);
649+
setTimeout(function () { module.remove.error(); }, settings.errorDuration);
650650
}
651651
}
652652
module.debug('API Request failed', errorMessage, xhr);
@@ -970,7 +970,7 @@
970970
});
971971
}
972972
clearTimeout(module.performance.timer);
973-
module.performance.timer = setTimeout(module.performance.display, 500);
973+
module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
974974
},
975975
display: function () {
976976
var

src/definitions/behaviors/form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@
14941494
});
14951495
}
14961496
clearTimeout(module.performance.timer);
1497-
module.performance.timer = setTimeout(module.performance.display, 500);
1497+
module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
14981498
},
14991499
display: function () {
15001500
var

src/definitions/behaviors/state.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@
482482
});
483483
}
484484
clearTimeout(module.performance.timer);
485-
module.performance.timer = setTimeout(module.performance.display, 500);
485+
module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
486486
},
487487
display: function () {
488488
var

src/definitions/behaviors/visibility.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@
10881088
});
10891089
}
10901090
clearTimeout(module.performance.timer);
1091-
module.performance.timer = setTimeout(module.performance.display, 500);
1091+
module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
10921092
},
10931093
display: function () {
10941094
var

src/definitions/globals/site.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
});
293293
}
294294
clearTimeout(module.performance.timer);
295-
module.performance.timer = setTimeout(module.performance.display, 500);
295+
module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
296296
},
297297
display: function () {
298298
var

src/definitions/modules/accordion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@
438438
});
439439
}
440440
clearTimeout(module.performance.timer);
441-
module.performance.timer = setTimeout(module.performance.display, 500);
441+
module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
442442
},
443443
display: function () {
444444
var

src/definitions/modules/calendar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@
14791479
});
14801480
}
14811481
clearTimeout(module.performance.timer);
1482-
module.performance.timer = setTimeout(module.performance.display, 500);
1482+
module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
14831483
},
14841484
display: function () {
14851485
var

src/definitions/modules/checkbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@
723723
});
724724
}
725725
clearTimeout(module.performance.timer);
726-
module.performance.timer = setTimeout(module.performance.display, 500);
726+
module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
727727
},
728728
display: function () {
729729
var

src/definitions/modules/dimmer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@
528528
});
529529
}
530530
clearTimeout(module.performance.timer);
531-
module.performance.timer = setTimeout(module.performance.display, 500);
531+
module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
532532
},
533533
display: function () {
534534
var

src/definitions/modules/dropdown.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@
12311231
module.set.filtered();
12321232
}
12331233
clearTimeout(module.timer);
1234-
module.timer = setTimeout(module.search, settings.delay.search);
1234+
module.timer = setTimeout(function () { module.search(); }, settings.delay.search);
12351235
},
12361236
label: {
12371237
click: function (event) {
@@ -3742,12 +3742,12 @@
37423742
show: function () {
37433743
module.verbose('Delaying show event to ensure user intent');
37443744
clearTimeout(module.timer);
3745-
module.timer = setTimeout(module.show, settings.delay.show);
3745+
module.timer = setTimeout(function () { module.show(); }, settings.delay.show);
37463746
},
37473747
hide: function () {
37483748
module.verbose('Delaying hide event to ensure user intent');
37493749
clearTimeout(module.timer);
3750-
module.timer = setTimeout(module.hide, settings.delay.hide);
3750+
module.timer = setTimeout(function () { module.hide(); }, settings.delay.hide);
37513751
},
37523752
},
37533753

@@ -3873,7 +3873,7 @@
38733873
});
38743874
}
38753875
clearTimeout(module.performance.timer);
3876-
module.performance.timer = setTimeout(module.performance.display, 500);
3876+
module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
38773877
},
38783878
display: function () {
38793879
var

0 commit comments

Comments
 (0)