]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix: check HTMLAnchorElement in saveAs for mini-program (#966) (#967)
authorodex21 <38051167+odex21@users.noreply.github.com>
Wed, 19 Jan 2022 14:33:21 +0000 (22:33 +0800)
committerGitHub <noreply@github.com>
Wed, 19 Jan 2022 14:33:21 +0000 (15:33 +0100)
packages/pinia/src/devtools/file-saver.ts

index bc4016f3b4e50f90f022457cf80a39683b15d16a..e314afc40bd8f922e62d96e431f77d99f8084aae 100644 (file)
@@ -112,8 +112,10 @@ export type SaveAs =
 
 export const saveAs: SaveAs = !IS_CLIENT
   ? () => {} // noop
-  : // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView
-  'download' in HTMLAnchorElement.prototype && !isMacOSWebView
+  : // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program
+  typeof HTMLAnchorElement !== 'undefined' &&
+    'download' in HTMLAnchorElement.prototype &&
+    !isMacOSWebView
   ? downloadSaveAs
   : // Use msSaveOrOpenBlob as a second approach
   'msSaveOrOpenBlob' in _navigator