From: Eduardo San Martin Morote Date: Fri, 25 Jun 2021 16:43:26 +0000 (+0200) Subject: refactor: fix tests X-Git-Tag: v2.0.0-beta.5~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6cdb9e3e6b4490d88a5adfb7a78e422ba97769a;p=thirdparty%2Fvuejs%2Fpinia.git refactor: fix tests --- diff --git a/src/devtools/file-saver.ts b/src/devtools/file-saver.ts index 16997054..7731d725 100644 --- a/src/devtools/file-saver.ts +++ b/src/devtools/file-saver.ts @@ -90,13 +90,16 @@ function click(node: Element) { } } +const _navigator = + /*#__PURE__*/ typeof navigator === 'object' ? navigator : { userAgent: '' } + // Detect WebView inside a native macOS app by ruling out all browsers // We just need to check for 'Safari' because all other browsers (besides Firefox) include that too // https://www.whatismybrowser.com/guides/the-latest-user-agent/macos const isMacOSWebView = /*#__PURE__*/ (() => - /Macintosh/.test(navigator.userAgent) && - /AppleWebKit/.test(navigator.userAgent) && - !/Safari/.test(navigator.userAgent))() + /Macintosh/.test(_navigator.userAgent) && + /AppleWebKit/.test(_navigator.userAgent) && + !/Safari/.test(_navigator.userAgent))() export type SaveAs = | ((blob: Blob, name?: string, opts?: Options) => void) @@ -113,7 +116,7 @@ export const saveAs: SaveAs = !IS_CLIENT 'download' in HTMLAnchorElement.prototype && !isMacOSWebView ? downloadSaveAs : // Use msSaveOrOpenBlob as a second approach - 'msSaveOrOpenBlob' in navigator + 'msSaveOrOpenBlob' in _navigator ? msSaveAs : // Fallback to using FileReader and a popup fileSaverSaveAs