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

Unified Diff: lib/filterComposer.js

Issue 29715577: Issue 6449 - Switch to Harmony modules (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Add lib/.eslintrc.json Created March 6, 2018, 10:30 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/filterComposer.js
===================================================================
--- a/lib/filterComposer.js
+++ b/lib/filterComposer.js
@@ -12,39 +12,34 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
/** @module filterComposer */
-"use strict";
-
-const {defaultMatcher} = require("matcher");
-const {RegExpFilter} = require("filterClasses");
-const {FilterNotifier} = require("filterNotifier");
-const {Prefs} = require("prefs");
-const {extractHostFromFrame, stringifyURL, isThirdParty} = require("url");
-const {getKey, checkWhitelisted} = require("whitelisting");
-const {port} = require("messaging");
-const info = require("info");
+import {defaultMatcher} from "matcher";
+import {RegExpFilter} from "filterClasses";
+import {FilterNotifier} from "filterNotifier";
+import {Prefs} from "prefs";
+import {extractHostFromFrame, stringifyURL, isThirdParty} from "url";
+import {getKey, checkWhitelisted} from "whitelisting";
+import {port} from "messaging";
+import info from "info";
let readyPages = new ext.PageMap();
/**
* Checks whether the given page is ready to use the filter composer
*
* @param {Page} page
* @return {boolean}
*/
-exports.isPageReady = page =>
-{
- return readyPages.has(page);
-};
+export const isPageReady = page => readyPages.has(page);
function isValidString(s)
{
return s && s.indexOf("\0") == -1;
}
function escapeChar(chr)
{
@@ -55,42 +50,36 @@
// in elemhide filters, and therefore must be escaped based on their
// char code as well.
if (code <= 0x1F || code == 0x7F || /[\d{}]/.test(chr))
return "\\" + code.toString(16) + " ";
return "\\" + chr;
}
-let escapeCSS =
/**
* Escapes a token (e.g. tag, id, class or attribute) to be used in
* CSS selectors.
*
* @param {string} s
* @return {string}
* @static
*/
-exports.escapeCSS = s =>
-{
- return s.replace(/^[\d-]|[^\w\-\u0080-\uFFFF]/g, escapeChar);
-};
+export const escapeCSS = s => s.replace(/^[\d-]|[^\w\-\u0080-\uFFFF]/g,
+ escapeChar);
-let quoteCSS =
/**
* Quotes a string to be used as attribute value in CSS selectors.
*
* @param {string} value
* @return {string}
* @static
*/
-exports.quoteCSS = value =>
-{
- return '"' + value.replace(/["\\{}\x00-\x1F\x7F]/g, escapeChar) + '"';
-};
+export const quoteCSS = value => '"' + value.replace(/["\\{}\x00-\x1F\x7F]/g,
+ escapeChar) + '"';
function composeFilters(details)
{
let {page, frame} = details;
let filters = [];
let selectors = [];
if (!checkWhitelisted(page, frame))
« lib/.eslintrc.json ('K') | « lib/devtools.js ('k') | lib/filterValidation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld