Skip to content

Commit 0f00c8b

Browse files
authored
fix: use const replace let (#1180)
1 parent f9a34d5 commit 0f00c8b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/index.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ export type CustomScrollBehaviorCallback<T = unknown> = (
4646
actions: ScrollAction[]
4747
) => T
4848

49-
let isStandardScrollBehavior = (
49+
const isStandardScrollBehavior = (
5050
options: any
5151
): options is StandardBehaviorOptions =>
5252
options === Object(options) && Object.keys(options).length !== 0
5353

54-
let isCustomScrollBehavior = <T = unknown>(
54+
const isCustomScrollBehavior = <T = unknown>(
5555
options: any
5656
): options is CustomBehaviorOptions<T> =>
5757
typeof options === 'object' ? typeof options.behavior === 'function' : false
5858

59-
let getOptions = (options: any): StandardBehaviorOptions => {
59+
const getOptions = (options: any): StandardBehaviorOptions => {
6060
// Handle alignToTop for legacy reasons, to be compatible with the spec
6161
if (options === false) {
6262
return { block: 'end', inline: 'nearest' }
@@ -75,7 +75,7 @@ let getOptions = (options: any): StandardBehaviorOptions => {
7575
// Derived from code of Andy Desmarais
7676
// https://terodox.tech/how-to-tell-if-an-element-is-in-the-dom-including-the-shadow-dom/
7777
const isInDocument = (element: Node) => {
78-
var currentElement = element
78+
let currentElement = element
7979
while (currentElement && currentElement.parentNode) {
8080
if (currentElement.parentNode === document) {
8181
return true
@@ -131,8 +131,9 @@ function scrollIntoView<T = unknown>(
131131
return options.behavior(compute(target, options))
132132
}
133133

134-
let behavior = typeof options === 'boolean' ? undefined : options?.behavior
135-
for (let { el, top, left } of compute(target, getOptions(options))) {
134+
const behavior = typeof options === 'boolean' ? undefined : options?.behavior
135+
136+
for (const { el, top, left } of compute(target, getOptions(options))) {
136137
el.scroll({ top, left, behavior })
137138
}
138139
}

0 commit comments

Comments
 (0)