From d63cb81fb795c8d556f42ffd34e77fc4d00120c1 Mon Sep 17 00:00:00 2001 From: Abe Tomoaki Date: Fri, 11 Feb 2022 17:24:48 +0900 Subject: [PATCH] refactor: use `const` instead of `let`. (#153) --- src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index c373228..eacf748 100644 --- a/src/index.js +++ b/src/index.js @@ -27,11 +27,11 @@ export const VISIBLE_OPTIONS = { * @param {*} name optional name of the cookie */ export const getCookieConsentValue = (name = defaultCookieConsentName) => { - let cookieValue = Cookies.get(name); + const cookieValue = Cookies.get(name); // if the cookieValue is undefined check for the legacy cookie if (cookieValue === undefined) { - cookieValue = Cookies.get(getLegacyCookieName(name)); + return Cookies.get(getLegacyCookieName(name)); } return cookieValue; }; @@ -201,7 +201,7 @@ class CookieConsent extends Component { cookieSecurity = location ? location.protocol === "https:" : true; } - let cookieOptions = { expires, ...extraCookieOptions, sameSite, secure: cookieSecurity }; + const cookieOptions = { expires, ...extraCookieOptions, sameSite, secure: cookieSecurity }; // Fallback for older browsers where can not set SameSite=None, SEE: https://web.dev/samesite-cookie-recipes/#handling-incompatible-clients if (sameSite === SAME_SITE_OPTIONS.NONE) { @@ -229,12 +229,12 @@ class CookieConsent extends Component { const { acceptOnScrollPercentage } = this.props; // (top / height) - height * 100 - let rootNode = document.documentElement, + const rootNode = document.documentElement, body = document.body, top = "scrollTop", height = "scrollHeight"; - let percentage = + const percentage = ((rootNode[top] || body[top]) / ((rootNode[height] || body[height]) - rootNode.clientHeight)) * 100;