@@ -89,35 +89,20 @@ function hasOwnProperty(obj, property) {
89
89
return Object . prototype . hasOwnProperty . call ( obj , property ) ;
90
90
}
91
91
92
- function usableLocalStorage ( ) {
93
- // Check if the browser supports localStorage at all:
94
- if ( typeof Storage === "undefined" ) {
95
- return false ;
96
- }
97
- // Check if we can access it; this access will fail if the browser
98
- // preferences deny access to localStorage, e.g., to prevent storage of
99
- // "cookies" (or cookie-likes, as is the case here).
100
- try {
101
- return window . localStorage !== null && window . localStorage !== undefined ;
102
- } catch ( err ) {
103
- // Storage is supported, but browser preferences deny access to it.
104
- return false ;
105
- }
106
- }
107
-
108
92
function updateLocalStorage ( name , value ) {
109
- if ( usableLocalStorage ( ) ) {
110
- localStorage [ name ] = value ;
111
- } else {
112
- // No Web Storage support so we do nothing
93
+ try {
94
+ window . localStorage . setItem ( name , value ) ;
95
+ } catch ( e ) {
96
+ // localStorage is not accessible, do nothing
113
97
}
114
98
}
115
99
116
100
function getCurrentValue ( name ) {
117
- if ( usableLocalStorage ( ) && localStorage [ name ] !== undefined ) {
118
- return localStorage [ name ] ;
101
+ try {
102
+ return window . localStorage . getItem ( name ) ;
103
+ } catch ( e ) {
104
+ return null ;
119
105
}
120
- return null ;
121
106
}
122
107
123
108
function switchTheme ( styleElem , mainStyleElem , newTheme , saveTheme ) {
0 commit comments