mirror of https://github.com/gorhill/uBlock.git
import fix to https://github.com/gorhill/uMatrix/issues/840
This commit is contained in:
parent
f09db15acb
commit
4f28301736
|
@ -97,31 +97,39 @@ vAPI.closePopup = function() {
|
|||
// This storage is optional, but it is nice to have, for a more polished user
|
||||
// experience.
|
||||
|
||||
// This can throw in some contexts (like in devtool).
|
||||
try {
|
||||
vAPI.localStorage = window.localStorage;
|
||||
} catch (ex) {
|
||||
}
|
||||
|
||||
// https://github.com/gorhill/uBlock/issues/2824
|
||||
// Use a dummy localStorage if for some reasons it's not available.
|
||||
if ( vAPI.localStorage instanceof Object === false ) {
|
||||
vAPI.localStorage = {
|
||||
length: 0,
|
||||
clear: function() {
|
||||
},
|
||||
getItem: function() {
|
||||
return null;
|
||||
},
|
||||
key: function() {
|
||||
throw new RangeError();
|
||||
},
|
||||
removeItem: function() {
|
||||
},
|
||||
setItem: function() {
|
||||
|
||||
// https://github.com/gorhill/uMatrix/issues/840
|
||||
// Always use a wrapper to seamlessly handle exceptions
|
||||
|
||||
vAPI.localStorage = {
|
||||
clear: function() {
|
||||
try {
|
||||
window.localStorage.clear();
|
||||
} catch(ex) {
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
getItem: function(key) {
|
||||
try {
|
||||
return window.localStorage.getItem(key);
|
||||
} catch(ex) {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
removeItem: function(key) {
|
||||
try {
|
||||
window.localStorage.removeItem(key);
|
||||
} catch(ex) {
|
||||
}
|
||||
},
|
||||
setItem: function(key, value) {
|
||||
try {
|
||||
window.localStorage.setItem(key, value);
|
||||
} catch(ex) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
Loading…
Reference in New Issue