mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 15:07:57 +01:00
Add util.makeXPath for constructing XPath expressions.
--HG-- extra : transplant_source : G%A7_%1B%9B%7BN%9C%FF%14%A9g%BA%04%99%B3%8B%23%ED%F2
This commit is contained in:
@@ -178,6 +178,20 @@ const util = { //{{{
|
||||
return dest;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an XPath union expression constructed from the specified node
|
||||
* tests. An expression is built with node tests for both the null and
|
||||
* XHTML namespaces. See {@link Buffer#evaluateXPath}.
|
||||
*
|
||||
* @param nodes {Array(string)}
|
||||
* @returns {string}
|
||||
*/
|
||||
makeXPath: function makeXPath(nodes)
|
||||
{
|
||||
return util.Array(nodes).map(function (node) [node, "xhtml:" + node]).flatten()
|
||||
.map(function (node) "//" + node).join(" | ");
|
||||
},
|
||||
|
||||
/**
|
||||
* Memoize the lookup of a property in an object.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user