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

Unified Diff: lib/filterValidation.js

Issue 29723558: Issue 6482 - Use ES6 classes (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created March 15, 2018, 7:46 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
« lib/compat.js ('K') | « lib/compat.js ('k') | lib/messaging.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
@@ -23,50 +23,52 @@
require("filterClasses");
/**
* An error returned by
* {@link module:filterValidation.parseFilter parseFilter()} or
* {@link module:filterValidation.parseFilters parseFilters()}
* indicating that a given filter cannot be parsed,
* contains an invalid CSS selector or is a filter list header.
- *
Manish Jethani 2018/03/15 07:54:11 See http://usejsdoc.org/howto-es2015-classes.html
- * @param {string} type See documentation in the constructor below.
- * @param {Object} [details] Contains the "reason" and / or "selector"
- * properties.
- * @constructor
*/
-function FilterParsingError(type, details)
+class FilterParsingError
{
/**
- * Indicates why the filter is rejected. Possible choices:
- * "invalid-filter", "invalid-css-selector", "unexpected-filter-list-header"
- *
- * @type {string}
+ * @param {string} type See documentation in the constructor below.
+ * @param {Object} [details] Contains the "reason" and / or "selector"
+ * properties.
*/
- this.type = type;
-
- if (details)
+ constructor(type, details)
{
- if ("reason" in details)
- this.reason = details.reason;
- if ("selector" in details)
- this.selector = details.selector;
+ /**
+ * Indicates why the filter is rejected. Possible choices:
+ * "invalid-filter", "invalid-css-selector", "unexpected-filter-list-header"
+ *
+ * @type {string}
+ */
+ this.type = type;
+
+ /**
+ * The line number the error occurred on if
+ * {@link module:filterValidation.parseFilters parseFilters()}
+ * were used. Or null if the error was returned by
+ * {@link module:filterValidation.parseFilter parseFilter()}.
+ *
+ * @type {?number}
+ */
+ this.lineno = null;
+
+ if (details)
+ {
+ if ("reason" in details)
+ this.reason = details.reason;
+ if ("selector" in details)
+ this.selector = details.selector;
+ }
}
-}
-FilterParsingError.prototype = {
- /**
- * The line number the error occurred on if
- * {@link module:filterValidation.parseFilters parseFilters()}
- * were used. Or null if the error was returned by
- * {@link module:filterValidation.parseFilter parseFilter()}.
- *
- * @type {?number}
- */
- lineno: null,
Manish Jethani 2018/03/15 07:54:11 Again, there's no real need for this to live on th
/**
* Returns a detailed translated error message.
*
* @return {string}
*/
toString()
{
@@ -84,17 +86,17 @@
if (this.lineno)
{
message = browser.i18n.getMessage(
"line", this.lineno.toLocaleString()
) + ": " + message;
}
return message;
}
-};
+}
function isValidCSSSelector(selector)
{
let style = document.createElement("style");
document.documentElement.appendChild(style);
let {sheet} = style;
document.documentElement.removeChild(style);
« lib/compat.js ('K') | « lib/compat.js ('k') | lib/messaging.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld