refactor: use const instead of let. (#153)

This commit is contained in:
Abe Tomoaki 2022-02-11 17:24:48 +09:00 committed by GitHub
parent e96b4fe4c0
commit d63cb81fb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,11 +27,11 @@ export const VISIBLE_OPTIONS = {
* @param {*} name optional name of the cookie * @param {*} name optional name of the cookie
*/ */
export const getCookieConsentValue = (name = defaultCookieConsentName) => { 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 the cookieValue is undefined check for the legacy cookie
if (cookieValue === undefined) { if (cookieValue === undefined) {
cookieValue = Cookies.get(getLegacyCookieName(name)); return Cookies.get(getLegacyCookieName(name));
} }
return cookieValue; return cookieValue;
}; };
@ -201,7 +201,7 @@ class CookieConsent extends Component {
cookieSecurity = location ? location.protocol === "https:" : true; 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 // 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) { if (sameSite === SAME_SITE_OPTIONS.NONE) {
@ -229,12 +229,12 @@ class CookieConsent extends Component {
const { acceptOnScrollPercentage } = this.props; const { acceptOnScrollPercentage } = this.props;
// (top / height) - height * 100 // (top / height) - height * 100
let rootNode = document.documentElement, const rootNode = document.documentElement,
body = document.body, body = document.body,
top = "scrollTop", top = "scrollTop",
height = "scrollHeight"; height = "scrollHeight";
let percentage = const percentage =
((rootNode[top] || body[top]) / ((rootNode[top] || body[top]) /
((rootNode[height] || body[height]) - rootNode.clientHeight)) * ((rootNode[height] || body[height]) - rootNode.clientHeight)) *
100; 100;