Skip to content

Commit

Permalink
[Fixes SRR (window is not defined)] Correctly validates if window obj…
Browse files Browse the repository at this point in the history
…ect exists (Hacker0x01#1742)
  • Loading branch information
senvolodymyr authored and martijnrusschen committed May 30, 2019
1 parent 77c5dc2 commit 36da6cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/date_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export function getDaysDiff(date1, date2) {
// ** Date Localization **

export function registerLocale(localeName, localeData) {
const scope = window || global;
const scope = typeof window !== "undefined" ? window : global;

if (!scope.__localeData__) {
scope.__localeData__ = {};
Expand All @@ -264,21 +264,21 @@ export function registerLocale(localeName, localeData) {
}

export function setDefaultLocale(localeName) {
const scope = window || global;
const scope = typeof window !== "undefined" ? window : global;

scope.__localeId__ = localeName;
}

export function getDefaultLocale() {
const scope = window || global;
const scope = typeof window !== "undefined" ? window : global;

return scope.__localeId__;
}

export function getLocaleObject(localeSpec) {
if (typeof localeSpec === "string") {
// Treat it as a locale name registered by registerLocale
const scope = window || global;
const scope = typeof window !== "undefined" ? window : global;
return scope.__localeData__ ? scope.__localeData__[localeSpec] : null;
} else {
// Treat it as a raw date-fns locale object
Expand Down

0 comments on commit 36da6cc

Please sign in to comment.