Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/subscriptionClasses.js

Issue 29802587: Issue 6559 - Change SpecialSubscription.defaultsMap to Map object (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 8, 2018, 2:45 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
};
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld