Index: lib/subscriptionClasses.js |
=================================================================== |
--- a/lib/subscriptionClasses.js |
+++ b/lib/subscriptionClasses.js |
@@ -19,17 +19,17 @@ |
/** |
* @fileOverview Definition of Subscription class and its subclasses. |
*/ |
const {ActiveFilter, BlockingFilter, |
WhitelistFilter, ElemHideBase} = require("./filterClasses"); |
const {FilterNotifier} = require("./filterNotifier"); |
-const {desc, extend} = require("./coreUtils"); |
+const {extend} = require("./coreUtils"); |
/** |
* Abstract base class for filter subscriptions |
* |
* @param {string} url download location of the subscription |
* @param {string} [title] title of the filter subscription |
* @constructor |
*/ |
@@ -255,17 +255,17 @@ |
* @return {boolean} |
*/ |
isDefaultFor(filter) |
{ |
if (this.defaults && this.defaults.length) |
{ |
for (let type of this.defaults) |
{ |
- if (filter instanceof SpecialSubscription.defaultsMap[type]) |
+ if (filter instanceof SpecialSubscription.defaultsMap.get(type)) |
return true; |
if (!(filter instanceof ActiveFilter) && type == "blacklist") |
return true; |
} |
} |
return false; |
}, |
@@ -276,30 +276,30 @@ |
*/ |
serialize(buffer) |
{ |
Subscription.prototype.serialize.call(this, buffer); |
if (this.defaults && this.defaults.length) |
{ |
buffer.push("defaults=" + |
this.defaults.filter( |
- type => type in SpecialSubscription.defaultsMap |
+ type => SpecialSubscription.defaultsMap.has(type) |
).join(" ") |
); |
} |
if (this._lastDownload) |
buffer.push("lastDownload=" + this._lastDownload); |
} |
}); |
-SpecialSubscription.defaultsMap = Object.create(null, desc({ |
- whitelist: WhitelistFilter, |
- blocking: BlockingFilter, |
- elemhide: ElemHideBase |
-})); |
+SpecialSubscription.defaultsMap = new Map([ |
+ ["whitelist", WhitelistFilter], |
+ ["blocking", BlockingFilter], |
+ ["elemhide", ElemHideBase] |
+]); |
/** |
* Creates a new user-defined filter group. |
* @param {string} [title] title of the new filter group |
* @return {SpecialSubscription} |
*/ |
SpecialSubscription.create = function(title) |
{ |
@@ -316,19 +316,19 @@ |
* This group will act as the default group for this filter type. |
* @param {Filter} filter |
* @return {SpecialSubscription} |
*/ |
SpecialSubscription.createForFilter = function(filter) |
{ |
let subscription = SpecialSubscription.create(); |
subscription.filters.push(filter); |
- for (let type in SpecialSubscription.defaultsMap) |
+ for (let [type, class_] of SpecialSubscription.defaultsMap) |
{ |
- if (filter instanceof SpecialSubscription.defaultsMap[type]) |
+ if (filter instanceof class_) |
subscription.defaults = [type]; |
} |
if (!subscription.defaults) |
subscription.defaults = ["blocking"]; |
return subscription; |
}; |
/** |