Index: ext/background.js |
=================================================================== |
--- a/ext/background.js |
+++ b/ext/background.js |
@@ -21,55 +21,56 @@ |
{ |
let nonEmptyPageMaps = new Set(); |
let PageMap = ext.PageMap = function() |
{ |
this._map = new Map(); |
}; |
PageMap.prototype = { |
- _delete(id) |
+ _deleteByPageId(id) |
{ |
- this._map.delete(id); |
- |
- if (this._map.size == 0) |
- nonEmptyPageMaps.delete(this); |
+ for (let page of this.keys().filter(page => page.id == id)) |
+ this.delete(page); |
}, |
keys() |
{ |
- return this._map.keys(); |
+ return Array.from(this._map.keys()); |
}, |
get(page) |
{ |
- return this._map.get(page.id); |
+ return this._map.get(page); |
}, |
set(page, value) |
{ |
- this._map.set(page.id, value); |
+ this._map.set(page, value); |
nonEmptyPageMaps.add(this); |
}, |
has(page) |
{ |
- return this._map.has(page.id); |
+ return this._map.has(page); |
}, |
clear() |
{ |
this._map.clear(); |
nonEmptyPageMaps.delete(this); |
}, |
delete(page) |
{ |
- this._delete(page.id); |
+ this._map.delete(page); |
+ |
+ if (this._map.size == 0) |
+ nonEmptyPageMaps.delete(this); |
} |
}; |
ext._removeFromAllPageMaps = pageId => |
{ |
for (let pageMap of nonEmptyPageMaps) |
- pageMap._delete(pageId); |
+ pageMap._deleteByPageId(pageId); |
}; |
/* Pages */ |
let Page = ext.Page = function(tab) |
{ |
this.id = tab.id; |
this._url = tab.url && new URL(tab.url); |