1
0
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:
Doug Kearns
2009-09-25 15:57:20 +10:00
parent 378fe9de1d
commit 4daa9ace53
3 changed files with 24 additions and 20 deletions

View File

@@ -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.
*