v1.0.0
First release of xpathway — a clean, standalone, XPath 1.0-compliant
evaluation library in zero-dependency ESM JavaScript, driving the browser's DOM
Level 3 XPath API on top of an injected DOM adapter (no Node implementation is
imported). Built to replace the unmaintained wgxpath blob in capybara-simulated
while staying reusable on any tree.
Features
- Full XPath 1.0: all 13 axes, every node test, predicates, the complete
operator set and type system (node-set / boolean / number / string with the
spec coercion rules), and the entire core function library. - Browser-compatible API:
createEvaluator(adapter)returns
evaluate/createExpression/createNSResolver, with results as an
XPathResult(full type constants and accessors). Grammar errors surface as
SyntaxError; host exception constructors are injectable. - HTML semantics (§6): in HTML documents, unprefixed element/attribute name
tests matchlocalNameASCII case-insensitively (scoped to the XHTML
namespace for elements); XML/XHTML and prefixed tests stay case-sensitive. - Performance: a parse cache, absolute-path hoisting memoized per evaluation
(//label[…]/@forruns once, not once per candidate), string-value
memoization, and iterative (stack-safe) axes. - Distribution: pure ESM, zero runtime dependencies, no Node built-ins —
bundleable with esbuild and runnable in a bare V8; noDate.now()/
Math.random()on the evaluation path.
Testing
- A staged conformance suite (
test/conformance/): an XPath 1.0 corpus plus the
real shapes Capybara'sxpathgem emits, and a vendored web-platform-tests
XPath case via a zero-dependency testharness shim. CI runs on Node 20/22/24.
MIT licensed.