Index: lib/elemHide.js |
diff --git a/lib/elemHide.js b/lib/elemHide.js |
index e99bb8a7f269e4df2370fb95bd950031503540b4..c38a5cd142a5cd36b6432a351f30370df1cf5ed4 100644 |
--- a/lib/elemHide.js |
+++ b/lib/elemHide.js |
@@ -31,10 +31,10 @@ const {FilterNotifier} = require("filterNotifier"); |
let filterByKey = []; |
/** |
- * Lookup table, keys of the filters by filter text |
- * @type {Object} |
+ * Lookup table, keys of the filters by filter |
+ * @type {Map.<Filter,string>} |
*/ |
-let keyByFilter = Object.create(null); |
+let keyByFilter = new Map(); |
/** |
* Nested lookup table, filter (or false if inactive) by filter key by domain. |
@@ -91,7 +91,7 @@ let ElemHide = exports.ElemHide = { |
clear() |
{ |
filterByKey = []; |
- keyByFilter = Object.create(null); |
+ keyByFilter = new Map(); |
filtersByDomain = new Map(); |
filterKeyBySelector = Object.create(null); |
unconditionalSelectors = unconditionalFilterKeys = null; |
@@ -143,11 +143,11 @@ let ElemHide = exports.ElemHide = { |
} |
else |
{ |
- if (filter.text in keyByFilter) |
+ if (keyByFilter.has(filter)) |
return; |
let key = filterByKey.push(filter) - 1; |
- keyByFilter[filter.text] = key; |
+ keyByFilter.set(filter, key); |
if (!(filter.domains || filter.selector in exceptions)) |
{ |
@@ -204,12 +204,12 @@ let ElemHide = exports.ElemHide = { |
} |
else |
{ |
- if (!(filter.text in keyByFilter)) |
+ let key = keyByFilter.get(filter); |
+ if (typeof key == "undefined") |
return; |
- let key = keyByFilter[filter.text]; |
delete filterByKey[key]; |
- delete keyByFilter[filter.text]; |
+ keyByFilter.delete(filter); |
this._removeFilterKey(key, filter); |
} |