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); |