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

Unified Diff: lib/elemHideEmulation.js

Issue 29784555: Issue 6665 - Abstract element hiding container logic into its own module Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created May 17, 2018, 5:15 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
« no previous file with comments | « lib/elemHide.js ('k') | lib/elemHideExceptions.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHideEmulation.js
===================================================================
--- a/lib/elemHideEmulation.js
+++ b/lib/elemHideEmulation.js
@@ -16,65 +16,35 @@
*/
"use strict";
/**
* @fileOverview Element hiding emulation implementation.
*/
+const {ElemHideTemplate} = require("./elemHide");
const {ElemHideExceptions} = require("./elemHideExceptions");
-const {Filter} = require("./filterClasses");
-
-let filters = new Set();
/**
* Container for element hiding emulation filters
* @class
*/
-let ElemHideEmulation = {
- /**
- * Removes all known filters
- */
- clear()
- {
- filters.clear();
- },
-
- /**
- * Add a new element hiding emulation filter
- * @param {ElemHideEmulationFilter} filter
- */
- add(filter)
- {
- filters.add(filter.text);
- },
-
- /**
- * Removes an element hiding emulation filter
- * @param {ElemHideEmulationFilter} filter
- */
- remove(filter)
- {
- filters.delete(filter.text);
- },
-
+exports.ElemHideEmulation = Object.assign(new ElemHideTemplate(), {
/**
* Returns a list of all rules active on a particular domain
* @param {string} domain
* @return {ElemHideEmulationFilter[]}
*/
getRulesForDomain(domain)
{
let result = [];
- for (let text of filters.values())
+ for (let filter of this._knownFilters)
{
- let filter = Filter.fromText(text);
if (filter.isActiveOnDomain(domain) &&
!ElemHideExceptions.getException(filter, domain))
{
result.push(filter);
}
}
return result;
}
-};
-exports.ElemHideEmulation = ElemHideEmulation;
+});
« no previous file with comments | « lib/elemHide.js ('k') | lib/elemHideExceptions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld