Skip to content

Commit 85daefb

Browse files
authored
fix: check HTMLAnchorElement in saveAs for mini-program (#966) (#967)
1 parent 5029327 commit 85daefb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/pinia/src/devtools/file-saver.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ export type SaveAs =
112112

113113
export const saveAs: SaveAs = !IS_CLIENT
114114
? () => {} // noop
115-
: // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView
116-
'download' in HTMLAnchorElement.prototype && !isMacOSWebView
115+
: // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program
116+
typeof HTMLAnchorElement !== 'undefined' &&
117+
'download' in HTMLAnchorElement.prototype &&
118+
!isMacOSWebView
117119
? downloadSaveAs
118120
: // Use msSaveOrOpenBlob as a second approach
119121
'msSaveOrOpenBlob' in _navigator

0 commit comments

Comments
 (0)