Skip to content
Permalink
Browse files

Noissue - Merge next into master

  • Loading branch information...
mjethani committed Feb 7, 2019
2 parents 7dbc0c7 + e60ecc5 commit 34c49bbf029e586226220c067c50cec6e8bf8842
Showing with 228 additions and 75 deletions.
  1. +39 −29 lib/filterClasses.js
  2. +185 −43 lib/matcher.js
  3. +4 −3 test/filterClasses.js
@@ -498,10 +498,10 @@ ActiveFilter.prototype = extend(Filter, {

if (this.domainSource)
{
// For some filter types this property is accessed only rarely,
// For most filter types this property is accessed only rarely,
// especially when the subscriptions are initially loaded. We defer any
// caching for such filters.
let {cacheDomains} = this;
// caching by default.
let cacheDomains = this._cacheDomains;

let source = this.domainSource.toLowerCase();

@@ -560,17 +560,17 @@ ActiveFilter.prototype = extend(Filter, {
}
}

this._cacheDomains = true;

return domains;
},

/**
* Whether the value of {@link ActiveFilter#domains} should be cached.
* Defaults to <code>true</code>, but may be overridden by subclasses that
* don't want the value to be cached (for better memory usage).
* @type {boolean}
* @protected
* @private
*/
cacheDomains: true,
_cacheDomains: false,

/**
* Array containing public keys of websites that this filter should apply to
@@ -764,6 +764,7 @@ RegExpFilter.prototype = extend(ActiveFilter, {
* Number of filters contained, will always be 1 (required to
* optimize {@link Matcher}).
* @type {number}
* @package
*/
size: 1,

@@ -876,6 +877,25 @@ RegExpFilter.prototype = extend(ActiveFilter, {
this.isActiveOnDomain(docDomain, sitekey)));
},

/**
* Checks whether the given URL matches this filter without checking the
* filter's domains.
* @param {string} location
* @param {number} typeMask
* @param {boolean} [thirdParty]
* @param {string} [sitekey]
* @return {boolean}
* @package
*/
matchesWithoutDomain(location, typeMask, thirdParty, sitekey)
{
return (this.contentType & typeMask) != 0 &&
(this.thirdParty == null || this.thirdParty == thirdParty) &&
this.matchesLocation(location) &&
(!this.sitekeys ||
(sitekey && this.sitekeys.includes(sitekey.toUpperCase())));
},

/**
* Checks whether the given URL matches this filter's pattern.
* @param {string} location The URL to check.
@@ -933,12 +953,24 @@ RegExpFilter.prototype = extend(ActiveFilter, {
/**
* Yields the filter itself (required to optimize {@link Matcher}).
* @yields {RegExpFilter}
* @package
*/
RegExpFilter.prototype[Symbol.iterator] = function*()
{
yield this;
};

/**
* Yields a key-value pair consisting of the filter itself and the value
* <code>true</code> (required to optimize {@link Matcher}).
* @yields {Array}
* @package
*/
RegExpFilter.prototype.entries = function*()
{
yield [this, true];
};

/**
* Creates a RegExp filter from its text representation
* @param {string} text same as in Filter()
@@ -1330,28 +1362,6 @@ function ElemHideBase(text, domains, selector)
exports.ElemHideBase = ElemHideBase;

ElemHideBase.prototype = extend(ContentFilter, {
/**
* @see ActiveFilter#domains
* @type {?Map.<string,boolean>}
*/
get domains()
{
let {get} = Object.getOwnPropertyDescriptor(ActiveFilter.prototype,
"domains");
let value = get.call(this);
this.cacheDomains = true;
return value;
},

/**
* Initially <code>false</code>, but set to <code>true</code> after
* {@link ActiveFilter#domains} has been accessed once.
* @see ActiveFilter#cacheDomains
* @type {boolean}
* @protected
*/
cacheDomains: false,

/**
* CSS selector for the HTML elements that should be hidden
* @type {string}
Oops, something went wrong.

0 comments on commit 34c49bb

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.