mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 15:22:26 +01:00
Add validation to revision d91ffd3a7b40.
This commit is contained in:
@@ -693,6 +693,18 @@ function compileMatcher(list) {
|
||||
});
|
||||
}
|
||||
|
||||
function validateMatcher(values) {
|
||||
let evaluator = services.XPathEvaluator();
|
||||
let node = util.xmlToDom(<div/>, document);
|
||||
return this.testValues(values, function (value) {
|
||||
if (/^xpath:/.test(value))
|
||||
evaluator.createExpression(value.substr(6), util.evaluateXPath.resolver);
|
||||
else
|
||||
node.querySelector(value);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
var Hints = Module("hints", {
|
||||
init: function init() {
|
||||
this.resizeTimer = Timer(100, 500, function () {
|
||||
@@ -1205,7 +1217,7 @@ var Hints = Module("hints", {
|
||||
value.matcher = compileMatcher(Option.splitList(value.result));
|
||||
return vals;
|
||||
},
|
||||
validator: Option.validateXPath
|
||||
validator: validateMatcher
|
||||
});
|
||||
|
||||
options.add(["hinttags", "ht"],
|
||||
@@ -1218,7 +1230,7 @@ var Hints = Module("hints", {
|
||||
this.matcher = compileMatcher(values);
|
||||
return values;
|
||||
},
|
||||
validator: Option.validateXPath
|
||||
validator: validateMatcher
|
||||
});
|
||||
|
||||
options.add(["hintkeys", "hk"],
|
||||
|
||||
@@ -687,13 +687,6 @@ var Option = Class("Option", {
|
||||
if (this.type === "regexpmap" || this.type === "sitemap")
|
||||
return Array.concat(values).every(function (re) acceptable.some(function (item) item[0] == re.result));
|
||||
return Array.concat(values).every(function (value) acceptable.some(function (item) item[0] == value));
|
||||
},
|
||||
|
||||
validateXPath: function (values) {
|
||||
return true; // For now.
|
||||
let evaluator = services.XPathEvaluator();
|
||||
return this.testValues(values,
|
||||
function (value) evaluator.createExpression(value, util.evaluateXPath.resolver));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -129,6 +129,8 @@
|
||||
- :delstyle, :styleenable, :styledisable and :styletoggle accept a !
|
||||
to operate on all styles. [b6]
|
||||
* IMPORTANT option changes:
|
||||
- 'hinttags' and 'extendedhinttags' now treat their values as
|
||||
CSS selectors by default. [b6]
|
||||
- Option value quoting has changed. List options will
|
||||
no longer be split at quoted commas and the option name, operators, and
|
||||
= sign may no longer be quoted. This will break certain
|
||||
|
||||
Reference in New Issue
Block a user