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

Unified Diff: lib/subscriptionClasses.js

Issue 29945631: Issue 7097 - Make element hiding filter objects ephemeral Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Simplify Created Nov. 18, 2018, 6:12 a.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
Index: lib/subscriptionClasses.js
===================================================================
--- a/lib/subscriptionClasses.js
+++ b/lib/subscriptionClasses.js
@@ -16,17 +16,17 @@
*/
"use strict";
/**
* @fileOverview Definition of Subscription class and its subclasses.
*/
-const {ActiveFilter, BlockingFilter,
+const {Filter, ActiveFilter, BlockingFilter,
WhitelistFilter, ElemHideBase} = require("./filterClasses");
const {filterNotifier} = require("./filterNotifier");
const {extend} = require("./coreUtils");
/**
* Abstract base class for filter subscriptions
*
* @param {string} url download location of the subscription
@@ -163,27 +163,30 @@
},
/**
* Yields the {@link Filter} object for each filter in the subscription.
* @yields {Filter}
*/
*filters()
{
- yield* this._filters;
+ for (let i = 0; i < this._filters.length; i++)
+ yield this._filters[i] || Filter.fromText(this._filterText[i], false);
},
/**
* Returns the {@link Filter} object at the given 0-based index.
* @param {number} index
* @returns {?Filter}
*/
filterAt(index)
{
- return this._filters[index] || null;
+ return this._filters[index] ||
+ (index >= 0 && index < this._filters.length ?
+ Filter.fromText(this._filterText[index], false) : null);
},
/**
* Returns the 0-based index of the given filter.
* @param {Filter} filter
* @param {number} [fromIndex] The index from which to start the search.
* @return {number}
*/
@@ -259,16 +262,22 @@
},
/**
* Clears any in-memory caches held by the object.
* @package
*/
clearCaches()
{
+ for (let i = 0; i < this._filters.length; i++)
+ {
+ if (this._filters[i] && this._filters[i].ephemeral)
+ this._filters[i] = null;
+ }
+
this._filterTextLookup = null;
},
/**
* Serializes the subscription for writing out on disk.
* @yields {string}
*/
*serialize()
« lib/filterClasses.js ('K') | « lib/iniParser.js ('k') | lib/synchronizer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld