diff --git a/.gitignore b/.gitignore index 79681bfbf..26cd5c38d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ lib umd +node_modules diff --git a/modules/DOMStateStorage.js b/modules/DOMStateStorage.js index 5fed69d98..8e8b93be0 100644 --- a/modules/DOMStateStorage.js +++ b/modules/DOMStateStorage.js @@ -1,3 +1,5 @@ +import warning from 'warning' + /*eslint-disable no-empty */ const KeyPrefix = '@@History/' @@ -6,7 +8,14 @@ function createKey(key) { } export function saveState(key, state) { - window.sessionStorage.setItem(createKey(key), JSON.stringify(state)) + try { + window.sessionStorage.setItem(createKey(key), JSON.stringify(state)) + } catch (error) { + if (error.name === 'QuotaExceededError') + return warning(null, 'sessionStore is not accessible in incognito mode') + + throw error + } } export function readState(key) {