@@ -89,35 +89,20 @@ function hasOwnProperty(obj, property) {
8989 return Object . prototype . hasOwnProperty . call ( obj , property ) ;
9090}
9191
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-
10892function 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
11397 }
11498}
11599
116100function 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 ;
119105 }
120- return null ;
121106}
122107
123108function switchTheme ( styleElem , mainStyleElem , newTheme , saveTheme ) {
0 commit comments