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

Unified Diff: lib/subscriptionClasses.js

Issue 29350382: Issue 4353 - Remove deprecated __proto__ syntax (Closed)
Patch Set: Missed a file... Created Sept. 1, 2016, 11:52 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
« lib/coreUtils.js ('K') | « lib/filterNotifier.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/subscriptionClasses.js
diff --git a/lib/subscriptionClasses.js b/lib/subscriptionClasses.js
index f559cb3937f42a8caff29135c7799e90c598183f..d58a9923c0b5c7bb906010f5ac51ab2ca9c4971c 100644
--- a/lib/subscriptionClasses.js
+++ b/lib/subscriptionClasses.js
@@ -21,6 +21,7 @@
let {ActiveFilter, BlockingFilter, WhitelistFilter, ElemHideBase} = require("filterClasses");
let {FilterNotifier} = require("filterNotifier");
+let {desc} = require("coreUtils");
/**
* Abstract base class for filter subscriptions
@@ -229,10 +230,7 @@ function SpecialSubscription(url, title)
}
exports.SpecialSubscription = SpecialSubscription;
-SpecialSubscription.prototype =
-{
- __proto__: Subscription.prototype,
-
+SpecialSubscription.prototype = Object.create(Subscription.prototype, desc({
/**
* Filter types that should be added to this subscription by default
* (entries should correspond to keys in SpecialSubscription.defaultsMap).
@@ -272,14 +270,13 @@ SpecialSubscription.prototype =
if (this._lastDownload)
buffer.push("lastDownload=" + this._lastDownload);
}
-};
+}));
-SpecialSubscription.defaultsMap = {
- __proto__: null,
+SpecialSubscription.defaultsMap = Object.create(null, desc({
"whitelist": WhitelistFilter,
"blocking": BlockingFilter,
"elemhide": ElemHideBase
-};
+}));
/**
* Creates a new user-defined filter group.
@@ -327,10 +324,7 @@ function RegularSubscription(url, title)
}
exports.RegularSubscription = RegularSubscription;
-RegularSubscription.prototype =
-{
- __proto__: Subscription.prototype,
-
+RegularSubscription.prototype = Object.create(Subscription.prototype, desc({
_homepage: null,
_lastDownload: 0,
@@ -338,38 +332,42 @@ RegularSubscription.prototype =
* Filter subscription homepage if known
* @type String
*/
- get homepage()
- {
- return this._homepage;
- },
- set homepage(value)
- {
- if (value != this._homepage)
+ homepage: {
+ get: function()
{
- let oldValue = this._homepage;
- this._homepage = value;
- FilterNotifier.triggerListeners("subscription.homepage", this, value, oldValue);
+ return this._homepage;
+ },
+ set: function(value)
+ {
+ if (value != this._homepage)
+ {
+ let oldValue = this._homepage;
+ this._homepage = value;
+ FilterNotifier.triggerListeners("subscription.homepage", this, value, oldValue);
+ }
+ return this._homepage;
}
- return this._homepage;
},
/**
* Time of the last subscription download (in seconds since the beginning of the epoch)
* @type Number
*/
- get lastDownload()
- {
- return this._lastDownload;
- },
- set lastDownload(value)
- {
- if (value != this._lastDownload)
+ lastDownload: {
+ get: function()
+ {
+ return this._lastDownload;
+ },
+ set: function(value)
{
- let oldValue = this._lastDownload;
- this._lastDownload = value;
- FilterNotifier.triggerListeners("subscription.lastDownload", this, value, oldValue);
+ if (value != this._lastDownload)
+ {
+ let oldValue = this._lastDownload;
+ this._lastDownload = value;
+ FilterNotifier.triggerListeners("subscription.lastDownload", this, value, oldValue);
+ }
+ return this._lastDownload;
}
- return this._lastDownload;
},
/**
@@ -383,7 +381,7 @@ RegularSubscription.prototype =
if (this._lastDownload)
buffer.push("lastDownload=" + this._lastDownload);
}
-};
+}));
/**
* Class for filter subscriptions updated externally (by other extension)
@@ -398,10 +396,7 @@ function ExternalSubscription(url, title)
}
exports.ExternalSubscription = ExternalSubscription;
-ExternalSubscription.prototype =
-{
- __proto__: RegularSubscription.prototype,
-
+ExternalSubscription.prototype = Object.create(RegularSubscription.prototype, desc({
/**
* See Subscription.serialize()
*/
@@ -409,7 +404,7 @@ ExternalSubscription.prototype =
{
throw new Error("Unexpected call, external subscriptions should not be serialized");
}
-};
+}));
/**
* Class for filter subscriptions updated externally (by other extension)
@@ -424,10 +419,7 @@ function DownloadableSubscription(url, title)
}
exports.DownloadableSubscription = DownloadableSubscription;
-DownloadableSubscription.prototype =
-{
- __proto__: RegularSubscription.prototype,
-
+DownloadableSubscription.prototype = Object.create(RegularSubscription.prototype, desc({
_downloadStatus: null,
_lastCheck: 0,
_errors: 0,
@@ -436,16 +428,18 @@ DownloadableSubscription.prototype =
* Status of the last download (ID of a string)
* @type String
*/
- get downloadStatus()
- {
- return this._downloadStatus;
- },
- set downloadStatus(value)
- {
- let oldValue = this._downloadStatus;
- this._downloadStatus = value;
- FilterNotifier.triggerListeners("subscription.downloadStatus", this, value, oldValue);
- return this._downloadStatus;
+ downloadStatus: {
+ get: function()
+ {
+ return this._downloadStatus;
+ },
+ set: function(value)
+ {
+ let oldValue = this._downloadStatus;
+ this._downloadStatus = value;
+ FilterNotifier.triggerListeners("subscription.downloadStatus", this, value, oldValue);
+ return this._downloadStatus;
+ }
},
/**
@@ -460,19 +454,21 @@ DownloadableSubscription.prototype =
* if the user doesn't use Adblock Plus for some time.
* @type Number
*/
- get lastCheck()
- {
- return this._lastCheck;
- },
- set lastCheck(value)
- {
- if (value != this._lastCheck)
+ lastCheck: {
+ get: function()
{
- let oldValue = this._lastCheck;
- this._lastCheck = value;
- FilterNotifier.triggerListeners("subscription.lastCheck", this, value, oldValue);
+ return this._lastCheck;
+ },
+ set: function(value)
+ {
+ if (value != this._lastCheck)
+ {
+ let oldValue = this._lastCheck;
+ this._lastCheck = value;
+ FilterNotifier.triggerListeners("subscription.lastCheck", this, value, oldValue);
+ }
+ return this._lastCheck;
}
- return this._lastCheck;
},
/**
@@ -491,19 +487,21 @@ DownloadableSubscription.prototype =
* Number of download failures since last success
* @type Number
*/
- get errors()
- {
- return this._errors;
- },
- set errors(value)
- {
- if (value != this._errors)
+ errors: {
+ get: function()
+ {
+ return this._errors;
+ },
+ set: function(value)
{
- let oldValue = this._errors;
- this._errors = value;
- FilterNotifier.triggerListeners("subscription.errors", this, value, oldValue);
+ if (value != this._errors)
+ {
+ let oldValue = this._errors;
+ this._errors = value;
+ FilterNotifier.triggerListeners("subscription.errors", this, value, oldValue);
+ }
+ return this._errors;
}
- return this._errors;
},
/**
@@ -549,4 +547,4 @@ DownloadableSubscription.prototype =
if (this.downloadCount)
buffer.push("downloadCount=" + this.downloadCount);
}
-};
+}));
« lib/coreUtils.js ('K') | « lib/filterNotifier.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld