Skip to content

Commit

Permalink
Use arrow functions to preserve this in timers
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Jul 20, 2023
1 parent c2d402c commit 268d1da
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/javascripts/components/copy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Copy.prototype.copyAction = function () {
}).on('success', function (e) {
e.trigger.textContent = 'Code copied'
e.clearSelection()
setTimeout(function () {
setTimeout(() => {
e.trigger.textContent = 'Copy code'
}, 5000)
})
Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/options-table.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const OptionsTable = {
}
detailsText.style.display = ''

window.setTimeout(function () {
window.setTimeout(() => {
tabLink.focus()
if (isLinkToTable) document.querySelector(hash).scrollIntoView()
}, 0)
Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Search.prototype.handleSearchQuery = function (query, callback) {
searchCallback = callback

clearTimeout(inputDebounceTimer)
inputDebounceTimer = setTimeout(function () {
inputDebounceTimer = setTimeout(() => {
trackSearchResults(searchQuery, searchResults)
}, DEBOUNCE_TIME_TO_WAIT())

Expand Down

0 comments on commit 268d1da

Please sign in to comment.