Fossil SCM

Corrected fossil.storage's use of hasOwnProperty() for the case of the fallback transient storage object.

stephan 2020-05-15 19:11 fileedit-ajaxify
Commit a863592e08d31a47438f16c447bfe83d3c355680797228ea586fa5cfd87d6591
1 file changed +10 -2
--- src/fossil.storage.js
+++ src/fossil.storage.js
@@ -45,11 +45,15 @@
4545
set: (k,v)=>$storage.setItem(k,v),
4646
/** Sets storage key k to JSON.stringify(v). */
4747
setJSON: (k,v)=>$storage.setItem(k,JSON.stringify(v)),
4848
/** Returns the value for the given storage key, or
4949
dflt if the key is not found in the storage. */
50
- get: (k,dflt)=>$storage.hasOwnProperty(k) ? $storage.getItem(k) : dflt,
50
+ get: function(k,dflt){
51
+ return (
52
+ this.isTransient() ? $storage.$ : $storage
53
+ ).hasOwnProperty(k) ? $storage.getItem(k) : dflt;
54
+ },
5155
/** Returns the JSON.parse()'d value of the given
5256
storage key's value, or dflt is the key is not
5357
found or JSON.parse() fails. */
5458
getJSON: function f(k,dflt){
5559
try {
@@ -58,11 +62,15 @@
5862
}
5963
catch(e){return dflt}
6064
},
6165
/** Returns true if the storage contains the given key,
6266
else false. */
63
- contains: (k)=>$storage.hasOwnProperty(k),
67
+ contains: function(k){
68
+ return (
69
+ this.isTransient() ? $storage.$ : $storage
70
+ ).hasOwnProperty(k);
71
+ },
6472
/** Removes the given key from the storage. */
6573
remove: (k)=>$storage.removeItem(k),
6674
/** Clears ALL keys from the storage. */
6775
clear: ()=>$storage.clear(),
6876
/** Returns an array of all keys currently in the storage. */
6977
--- src/fossil.storage.js
+++ src/fossil.storage.js
@@ -45,11 +45,15 @@
45 set: (k,v)=>$storage.setItem(k,v),
46 /** Sets storage key k to JSON.stringify(v). */
47 setJSON: (k,v)=>$storage.setItem(k,JSON.stringify(v)),
48 /** Returns the value for the given storage key, or
49 dflt if the key is not found in the storage. */
50 get: (k,dflt)=>$storage.hasOwnProperty(k) ? $storage.getItem(k) : dflt,
 
 
 
 
51 /** Returns the JSON.parse()'d value of the given
52 storage key's value, or dflt is the key is not
53 found or JSON.parse() fails. */
54 getJSON: function f(k,dflt){
55 try {
@@ -58,11 +62,15 @@
58 }
59 catch(e){return dflt}
60 },
61 /** Returns true if the storage contains the given key,
62 else false. */
63 contains: (k)=>$storage.hasOwnProperty(k),
 
 
 
 
64 /** Removes the given key from the storage. */
65 remove: (k)=>$storage.removeItem(k),
66 /** Clears ALL keys from the storage. */
67 clear: ()=>$storage.clear(),
68 /** Returns an array of all keys currently in the storage. */
69
--- src/fossil.storage.js
+++ src/fossil.storage.js
@@ -45,11 +45,15 @@
45 set: (k,v)=>$storage.setItem(k,v),
46 /** Sets storage key k to JSON.stringify(v). */
47 setJSON: (k,v)=>$storage.setItem(k,JSON.stringify(v)),
48 /** Returns the value for the given storage key, or
49 dflt if the key is not found in the storage. */
50 get: function(k,dflt){
51 return (
52 this.isTransient() ? $storage.$ : $storage
53 ).hasOwnProperty(k) ? $storage.getItem(k) : dflt;
54 },
55 /** Returns the JSON.parse()'d value of the given
56 storage key's value, or dflt is the key is not
57 found or JSON.parse() fails. */
58 getJSON: function f(k,dflt){
59 try {
@@ -58,11 +62,15 @@
62 }
63 catch(e){return dflt}
64 },
65 /** Returns true if the storage contains the given key,
66 else false. */
67 contains: function(k){
68 return (
69 this.isTransient() ? $storage.$ : $storage
70 ).hasOwnProperty(k);
71 },
72 /** Removes the given key from the storage. */
73 remove: (k)=>$storage.removeItem(k),
74 /** Clears ALL keys from the storage. */
75 clear: ()=>$storage.clear(),
76 /** Returns an array of all keys currently in the storage. */
77

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button