Skip to content

Commit

Permalink
check dom variables in server side environment
Browse files Browse the repository at this point in the history
  • Loading branch information
lhapaipai committed Sep 20, 2021
1 parent 37bcaf5 commit 687fa56
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/util/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const exported = {
return linkEl.href;
},

hardwareConcurrency: navigator && navigator.hardwareConcurrency || 4,
hardwareConcurrency: typeof navigator !== 'undefined' && navigator && navigator.hardwareConcurrency || 4,

get prefersReducedMotion(): boolean {
if (!matchMedia) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/util/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ DOM.createNS = function (namespaceURI: string, tagName: string) {
return el;
};

const docStyle = window.document && window.document.documentElement.style;
const docStyle = typeof window !== 'undefined' && window.document && window.document.documentElement.style;

function testProp(props) {
if (!docStyle) return props[0];
Expand Down

0 comments on commit 687fa56

Please sign in to comment.