From 85daefb7c3325d3cd258de9812cb117c393b8f99 Mon Sep 17 00:00:00 2001 From: odex21 <38051167+odex21@users.noreply.github.com> Date: Wed, 19 Jan 2022 22:33:21 +0800 Subject: [PATCH] fix: check HTMLAnchorElement in saveAs for mini-program (#966) (#967) --- packages/pinia/src/devtools/file-saver.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/pinia/src/devtools/file-saver.ts b/packages/pinia/src/devtools/file-saver.ts index bc4016f3..e314afc4 100644 --- a/packages/pinia/src/devtools/file-saver.ts +++ b/packages/pinia/src/devtools/file-saver.ts @@ -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 -- 2.47.3