mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
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
|
// This storage is optional, but it is nice to have, for a more polished user
|
||||||
// experience.
|
// experience.
|
||||||
|
|
||||||
// This can throw in some contexts (like in devtool).
|
|
||||||
try {
|
|
||||||
vAPI.localStorage = window.localStorage;
|
|
||||||
} catch (ex) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/2824
|
// https://github.com/gorhill/uBlock/issues/2824
|
||||||
// Use a dummy localStorage if for some reasons it's not available.
|
// Use a dummy localStorage if for some reasons it's not available.
|
||||||
if ( vAPI.localStorage instanceof Object === false ) {
|
|
||||||
vAPI.localStorage = {
|
// https://github.com/gorhill/uMatrix/issues/840
|
||||||
length: 0,
|
// Always use a wrapper to seamlessly handle exceptions
|
||||||
clear: function() {
|
|
||||||
},
|
vAPI.localStorage = {
|
||||||
getItem: function() {
|
clear: function() {
|
||||||
return null;
|
try {
|
||||||
},
|
window.localStorage.clear();
|
||||||
key: function() {
|
} catch(ex) {
|
||||||
throw new RangeError();
|
|
||||||
},
|
|
||||||
removeItem: function() {
|
|
||||||
},
|
|
||||||
setItem: function() {
|
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
}
|
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
Block a user