Fix SSR matchMedia shim

This commit is contained in:
Mononaut 2023-10-18 21:13:35 +00:00
parent a2b9b0c89d
commit cfdbd93695
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
2 changed files with 4 additions and 3 deletions

View File

@ -22,9 +22,10 @@ const win = domino.createWindow(template);
win.__env = global.__env;
// @ts-ignore
win.matchMedia = () => {
win.matchMedia = (media) => {
return {
matches: true
media,
matches: true,
};
};

View File

@ -323,7 +323,7 @@ export function hasTouchScreen(): boolean {
// @ts-ignore
hasTouchScreen = navigator.msMaxTouchPoints > 0;
} else {
const mQ = matchMedia?.('(pointer:coarse)');
const mQ = window.matchMedia?.('(pointer:coarse)');
if (mQ?.media === '(pointer:coarse)') {
hasTouchScreen = !!mQ.matches;
} else if ('orientation' in window) {