The best bet could be to try-catch and silently fail when saving to localStorage (depending if localStorage is critical for the app to work or not).
Since it would be mundane and error-prone to always wrap any localStorage.setItem call with a try-catch, you could create a global localStorageWrapper (and ban the direct localStorage access in JSHint for instance) like this (snippet for Object.create-supporting browsers)
Platforms:
Safari on iOS
Summary:
When a new tab is launched in private mode,
localStorage
has zero quota assigned and hence alwaysthrow
s when trying to write to it.Example:
Workarounds:
The best bet could be to
try-catch
and silently fail when saving tolocalStorage
(depending if localStorage is critical for the app to work or not).Since it would be mundane and error-prone to always wrap any
localStorage.setItem
call with atry-catch
, you could create a globallocalStorageWrapper
(and ban the directlocalStorage
access in JSHint for instance) like this (snippet forObject.create
-supporting browsers)StackOverflow discussions:
http://stackoverflow.com/questions/14555347/html5-localstorage-error-with-safari-quota-exceeded-err-dom-exception-22-an