Fossil SCM
Corrected fossil.storage's use of hasOwnProperty() for the case of the fallback transient storage object.
Commit
a863592e08d31a47438f16c447bfe83d3c355680797228ea586fa5cfd87d6591
Parent
d701631ec7cee22…
1 file changed
+10
-2
+10
-2
| --- src/fossil.storage.js | ||
| +++ src/fossil.storage.js | ||
| @@ -45,11 +45,15 @@ | ||
| 45 | 45 | set: (k,v)=>$storage.setItem(k,v), |
| 46 | 46 | /** Sets storage key k to JSON.stringify(v). */ |
| 47 | 47 | setJSON: (k,v)=>$storage.setItem(k,JSON.stringify(v)), |
| 48 | 48 | /** Returns the value for the given storage key, or |
| 49 | 49 | 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 | + }, | |
| 51 | 55 | /** Returns the JSON.parse()'d value of the given |
| 52 | 56 | storage key's value, or dflt is the key is not |
| 53 | 57 | found or JSON.parse() fails. */ |
| 54 | 58 | getJSON: function f(k,dflt){ |
| 55 | 59 | try { |
| @@ -58,11 +62,15 @@ | ||
| 58 | 62 | } |
| 59 | 63 | catch(e){return dflt} |
| 60 | 64 | }, |
| 61 | 65 | /** Returns true if the storage contains the given key, |
| 62 | 66 | else false. */ |
| 63 | - contains: (k)=>$storage.hasOwnProperty(k), | |
| 67 | + contains: function(k){ | |
| 68 | + return ( | |
| 69 | + this.isTransient() ? $storage.$ : $storage | |
| 70 | + ).hasOwnProperty(k); | |
| 71 | + }, | |
| 64 | 72 | /** Removes the given key from the storage. */ |
| 65 | 73 | remove: (k)=>$storage.removeItem(k), |
| 66 | 74 | /** Clears ALL keys from the storage. */ |
| 67 | 75 | clear: ()=>$storage.clear(), |
| 68 | 76 | /** Returns an array of all keys currently in the storage. */ |
| 69 | 77 |
| --- 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 |