Fix SSR matchMedia shim
This commit is contained in:
parent
a2b9b0c89d
commit
cfdbd93695
@ -22,9 +22,10 @@ const win = domino.createWindow(template);
|
|||||||
win.__env = global.__env;
|
win.__env = global.__env;
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
win.matchMedia = () => {
|
win.matchMedia = (media) => {
|
||||||
return {
|
return {
|
||||||
matches: true
|
media,
|
||||||
|
matches: true,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ export function hasTouchScreen(): boolean {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
hasTouchScreen = navigator.msMaxTouchPoints > 0;
|
hasTouchScreen = navigator.msMaxTouchPoints > 0;
|
||||||
} else {
|
} else {
|
||||||
const mQ = matchMedia?.('(pointer:coarse)');
|
const mQ = window.matchMedia?.('(pointer:coarse)');
|
||||||
if (mQ?.media === '(pointer:coarse)') {
|
if (mQ?.media === '(pointer:coarse)') {
|
||||||
hasTouchScreen = !!mQ.matches;
|
hasTouchScreen = !!mQ.matches;
|
||||||
} else if ('orientation' in window) {
|
} else if ('orientation' in window) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user