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

Unified Diff: lib/filterClasses.js

Issue 29350382: Issue 4353 - Remove deprecated __proto__ syntax (Closed)
Patch Set: Export extend function too, use Object.keys Created Sept. 2, 2016, 3:05 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 | « lib/coreUtils.js ('k') | lib/filterNotifier.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterClasses.js
diff --git a/lib/filterClasses.js b/lib/filterClasses.js
index 5a8ac6d77bf116ace79ceebbbf3df1b02dc11fc6..ddf9aff8ec82a7e1abdb8f81465bc53af9acb881 100644
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -20,6 +20,7 @@
*/
let {FilterNotifier} = require("filterNotifier");
+let {extend} = require("coreUtils");
/**
* Abstract base class for filters
@@ -210,10 +211,7 @@ function InvalidFilter(text, reason)
}
exports.InvalidFilter = InvalidFilter;
-InvalidFilter.prototype =
-{
- __proto__: Filter.prototype,
-
+InvalidFilter.prototype = extend(Filter, {
type: "invalid",
/**
@@ -226,7 +224,7 @@ InvalidFilter.prototype =
* See Filter.serialize()
*/
serialize: function(buffer) {}
-};
+});
/**
* Class for comments
@@ -240,17 +238,14 @@ function CommentFilter(text)
}
exports.CommentFilter = CommentFilter;
-CommentFilter.prototype =
-{
- __proto__: Filter.prototype,
-
+CommentFilter.prototype = extend(Filter, {
type: "comment",
/**
* See Filter.serialize()
*/
serialize: function(buffer) {}
-};
+});
/**
* Abstract base class for filters that can get hits
@@ -267,10 +262,7 @@ function ActiveFilter(text, domains)
}
exports.ActiveFilter = ActiveFilter;
-ActiveFilter.prototype =
-{
- __proto__: Filter.prototype,
-
+ActiveFilter.prototype = extend(Filter, {
_disabled: false,
_hitCount: 0,
_lastHit: 0,
@@ -515,7 +507,7 @@ ActiveFilter.prototype =
buffer.push("lastHit=" + this._lastHit);
}
}
-};
+});
/**
* Abstract base class for RegExp-based filters
@@ -556,10 +548,7 @@ function RegExpFilter(text, regexpSource, contentType, matchCase, domains, third
}
exports.RegExpFilter = RegExpFilter;
-RegExpFilter.prototype =
-{
- __proto__: ActiveFilter.prototype,
-
+RegExpFilter.prototype = extend(ActiveFilter, {
/**
* @see ActiveFilter.domainSourceIsUpperCase
*/
@@ -664,7 +653,7 @@ RegExpFilter.prototype =
return false;
}
-};
+});
// Required to optimize Matcher, see also RegExpFilter.prototype.length
Object.defineProperty(RegExpFilter.prototype, "0",
@@ -810,10 +799,7 @@ function BlockingFilter(text, regexpSource, contentType, matchCase, domains, thi
}
exports.BlockingFilter = BlockingFilter;
-BlockingFilter.prototype =
-{
- __proto__: RegExpFilter.prototype,
-
+BlockingFilter.prototype = extend(RegExpFilter, {
type: "blocking",
/**
@@ -821,7 +807,7 @@ BlockingFilter.prototype =
* @type Boolean
*/
collapse: null
-};
+});
/**
* Class for whitelist filters
@@ -841,12 +827,9 @@ function WhitelistFilter(text, regexpSource, contentType, matchCase, domains, th
}
exports.WhitelistFilter = WhitelistFilter;
-WhitelistFilter.prototype =
-{
- __proto__: RegExpFilter.prototype,
-
+WhitelistFilter.prototype = extend(RegExpFilter, {
type: "whitelist"
-};
+});
/**
* Base class for element hiding filters
@@ -866,10 +849,7 @@ function ElemHideBase(text, domains, selector)
}
exports.ElemHideBase = ElemHideBase;
-ElemHideBase.prototype =
-{
- __proto__: ActiveFilter.prototype,
-
+ElemHideBase.prototype = extend(ActiveFilter, {
/**
* @see ActiveFilter.domainSeparator
*/
@@ -890,7 +870,7 @@ ElemHideBase.prototype =
* @type String
*/
selector: null
-};
+});
/**
* Creates an element hiding filter from a pre-parsed text representation
@@ -975,12 +955,9 @@ function ElemHideFilter(text, domains, selector)
}
exports.ElemHideFilter = ElemHideFilter;
-ElemHideFilter.prototype =
-{
- __proto__: ElemHideBase.prototype,
-
+ElemHideFilter.prototype = extend(ElemHideBase, {
type: "elemhide"
-};
+});
/**
* Class for element hiding exceptions
@@ -996,12 +973,9 @@ function ElemHideException(text, domains, selector)
}
exports.ElemHideException = ElemHideException;
-ElemHideException.prototype =
-{
- __proto__: ElemHideBase.prototype,
-
+ElemHideException.prototype = extend(ElemHideBase, {
type: "elemhideexception"
-};
+});
/**
* Class for CSS property filters
@@ -1025,10 +999,7 @@ function CSSPropertyFilter(text, domains, selector, regexpSource,
}
exports.CSSPropertyFilter = CSSPropertyFilter;
-CSSPropertyFilter.prototype =
-{
- __proto__: ElemHideBase.prototype,
-
+CSSPropertyFilter.prototype = extend(ElemHideBase, {
type: "cssproperty",
/**
@@ -1067,4 +1038,4 @@ CSSPropertyFilter.prototype =
Object.defineProperty(this, "regexpString", {value: regexp});
return regexp;
}
-};
+});
« no previous file with comments | « lib/coreUtils.js ('k') | lib/filterNotifier.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld