xpath-ts2
Version:
DOM 3 and 4 XPath 1.0 implementation for browser and Node.js environment with support for typescript 5.
21 lines (17 loc) • 576 B
text/typescript
import { isNSResolver } from './utils/types';
export class XPathNSResolverWrapper {
xpathNSResolver: { lookupNamespaceURI(prefix: string | null): string | null; } | null;
constructor(r: XPathNSResolver | null) {
if (!isNSResolver(r)) {
this.xpathNSResolver = null;
} else {
this.xpathNSResolver = r as { lookupNamespaceURI(prefix: string | null): string | null; };
}
}
getNamespace(prefix: string, _n: Node) {
if (this.xpathNSResolver == null) {
return null;
}
return this.xpathNSResolver.lookupNamespaceURI(prefix);
}
}