File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,15 @@ type PersistOptions = {
15
15
export function persistResumableFields ( id : string , options ?: PersistOptions ) : void {
16
16
const selector = options ?. selector ?? '.js-session-resumable'
17
17
const keyPrefix = options ?. keyPrefix ?? 'session-resume:'
18
- const storage = options ?. storage ?? sessionStorage
18
+
19
+ let storage
20
+ try {
21
+ storage = options ?. storage ?? sessionStorage
22
+ } catch {
23
+ // Ignore browser private mode error and return early
24
+ return
25
+ }
26
+
19
27
const key = `${ keyPrefix } ${ id } `
20
28
const resumables = [ ]
21
29
@@ -50,7 +58,15 @@ type RestoreOptions = {keyPrefix?: string; storage?: Pick<Storage, 'getItem' | '
50
58
51
59
export function restoreResumableFields ( id : string , options ?: RestoreOptions ) : void {
52
60
const keyPrefix = options ?. keyPrefix ?? 'session-resume:'
53
- const storage = options ?. storage ?? sessionStorage
61
+
62
+ let storage
63
+ try {
64
+ storage = options ?. storage ?? sessionStorage
65
+ } catch {
66
+ // Ignore browser private mode error and return early
67
+ return
68
+ }
69
+
54
70
const key = `${ keyPrefix } ${ id } `
55
71
let fields
56
72
You can’t perform that action at this time.
0 commit comments