storage.js: Properly handle if keys are entirely removed
This commit is contained in:
parent
363486277b
commit
8937e11a09
|
@ -251,17 +251,20 @@
|
|||
* Update the map
|
||||
*
|
||||
* @param {object} newValue
|
||||
* @param {object} oldValue
|
||||
*/
|
||||
onChange: function(newValue, oldValue) {
|
||||
onChange: function(newValue) {
|
||||
// Check for deletions first. Uses keys() to iterate over a copy
|
||||
this.keys().forEach(function (key) {
|
||||
if (typeof newValue[key] === 'undefined') {
|
||||
if (newValue === null || typeof newValue[key] === 'undefined') {
|
||||
this.data.delete(key);
|
||||
$(window).trigger('StorageAwareMapDelete', key);
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (newValue === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Now check for new entries
|
||||
Object.keys(newValue).forEach(function(key) {
|
||||
var known = this.data.has(key);
|
||||
|
|
Loading…
Reference in New Issue