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

Unified Diff: lib/filterValidation.js

Issue 29452181: Noissue - Merge current tip to Edge bookmark (Closed)
Patch Set: Created May 30, 2017, 3:49 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/filterComposer.js ('k') | lib/icon.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterValidation.js
===================================================================
--- a/lib/filterValidation.js
+++ b/lib/filterValidation.js
@@ -1,6 +1,6 @@
/*
* This file is part of Adblock Plus <https://adblockplus.org/>,
- * Copyright (C) 2006-2016 Eyeo GmbH
+ * Copyright (C) 2006-2017 eyeo GmbH
*
* Adblock Plus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
@@ -29,6 +29,9 @@
* indicating that a given filter cannot be parsed,
* contains an invalid CSS selector or is a filter list header.
*
+ * @param {string} type See documentation in the constructor below.
+ * @param {Object} [details] Contains the "reason" and / or "selector"
+ * properties.
* @constructor
*/
function FilterParsingError(type, details)
@@ -71,14 +74,19 @@
if (this.reason)
message = Utils.getString(this.reason);
else
+ {
message = ext.i18n.getMessage(
this.type.replace(/-/g, "_"),
"selector" in this ? "'" + this.selector + "'" : null
);
+ }
if (this.lineno)
- message = ext.i18n.getMessage("line", this.lineno.toLocaleString()) + ": " + message;
-
+ {
+ message = ext.i18n.getMessage(
+ "line", this.lineno.toLocaleString()
+ ) + ": " + message;
+ }
return message;
}
};
@@ -87,7 +95,7 @@
{
let style = document.createElement("style");
document.documentElement.appendChild(style);
- let sheet = style.sheet;
+ let {sheet} = style;
document.documentElement.removeChild(style);
try
@@ -104,10 +112,10 @@
/**
* @typedef ParsedFilter
- * @property {?Filter} [filter] The parsed filter if it is valid.
- * Or null if the given string is empty.
- * @property {FilterParsingError} [error] See {@link module:filterValidation~FilterParsingError FilterParsingError}
- *
+ * @property {?Filter} [filter]
+ * The parsed filter if it is valid. Or null if the given string is empty.
+ * @property {FilterParsingError} [error]
+ * See {@link module:filterValidation~FilterParsingError FilterParsingError}
*/
let parseFilter =
@@ -130,19 +138,26 @@
filter = Filter.fromText(text);
if (filter instanceof InvalidFilter)
- return {error: new FilterParsingError("invalid-filter", {reason: filter.reason})};
-
+ {
+ return {error: new FilterParsingError("invalid-filter",
+ {reason: filter.reason})};
+ }
if (filter instanceof ElemHideBase && !isValidCSSSelector(filter.selector))
- return {error: new FilterParsingError("invalid-css-selector", {selector: filter.selector})};
+ {
+ return {error: new FilterParsingError("invalid-css-selector",
+ {selector: filter.selector})};
+ }
}
- return {filter: filter};
+ return {filter};
};
/**
* @typedef ParsedFilters
- * @property {Filter[]} filters The parsed result without invalid filters.
- * @property {FilterParsingError[]} errors See {@link module:filterValidation~FilterParsingError FilterParsingError}
+ * @property {Filter[]} filters
+ * The parsed result without invalid filters.
+ * @property {FilterParsingError[]} errors
+ * See {@link module:filterValidation~FilterParsingError FilterParsingError}
*/
/**
@@ -171,5 +186,5 @@
}
}
- return {filters: filters, errors: errors};
+ return {filters, errors};
};
« no previous file with comments | « lib/filterComposer.js ('k') | lib/icon.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld