mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:29:04 +01:00
Introduce addMatchMediaChangeListener with support for Safari 13.x
This commit is contained in:
@@ -1600,3 +1600,13 @@ export function getCookieValue(name: string): string | undefined {
|
||||
|
||||
return match ? match.pop() : undefined;
|
||||
}
|
||||
|
||||
export function addMatchMediaChangeListener(query: string, callback: () => void): void {
|
||||
const mediaQueryList = window.matchMedia(query);
|
||||
if (typeof mediaQueryList.addEventListener === 'function') {
|
||||
mediaQueryList.addEventListener('change', callback);
|
||||
} else {
|
||||
// Safari 13.x
|
||||
mediaQueryList.addListener(callback);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user