Skip to content

Commit dea5d92

Browse files
foolipgsnedders
authored andcommitted
Add the DOM XPath interfaces from the WHATWG wiki
See also https://wiki.whatwg.org/wiki/DOM_XPath. Prose still needs to be added, tracked by #67. This is a one-time exception from the normal WHATWG Working Mode as there's a lot of benefit in hosting these interfaces in a standard as they're implemented in all engines, despite them not being fully defined and tested. Co-Authored-By: Sam Sneddon <[email protected]>
1 parent a93f9f8 commit dea5d92

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

dom.bs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9855,6 +9855,88 @@ the given value.
98559855

98569856

98579857

9858+
<h2 id=xpath>XPath</h2>
9859+
9860+
<p class=XXX><cite>DOM Level 3 XPath</cite> defined an API for evaluating <cite>XPath 1.0</cite>
9861+
expressions. These APIs are widely implemented, but have not been maintained. The interface
9862+
definitions are maintained here so that they can be updated when <cite>Web IDL</cite> changes.
9863+
Complete definitions of these APIs remain necessary and such work is tracked and can be contributed
9864+
to in <a href="https://github.com/whatwg/dom/issues/67">whatwg/dom#67</a>. [[DOM-Level-3-XPath]]
9865+
[[XPath]] [[WEBIDL]]
9866+
9867+
9868+
<h3 id=interface-xpathresult>Interface {{XPathResult}}</h3>
9869+
9870+
<pre class=idl>
9871+
[Exposed=Window]
9872+
interface XPathResult {
9873+
const unsigned short ANY_TYPE = 0;
9874+
const unsigned short NUMBER_TYPE = 1;
9875+
const unsigned short STRING_TYPE = 2;
9876+
const unsigned short BOOLEAN_TYPE = 3;
9877+
const unsigned short UNORDERED_NODE_ITERATOR_TYPE = 4;
9878+
const unsigned short ORDERED_NODE_ITERATOR_TYPE = 5;
9879+
const unsigned short UNORDERED_NODE_SNAPSHOT_TYPE = 6;
9880+
const unsigned short ORDERED_NODE_SNAPSHOT_TYPE = 7;
9881+
const unsigned short ANY_UNORDERED_NODE_TYPE = 8;
9882+
const unsigned short FIRST_ORDERED_NODE_TYPE = 9;
9883+
9884+
readonly attribute unsigned short resultType;
9885+
readonly attribute unrestricted double numberValue;
9886+
readonly attribute DOMString stringValue;
9887+
readonly attribute boolean booleanValue;
9888+
readonly attribute Node? singleNodeValue;
9889+
readonly attribute boolean invalidIteratorState;
9890+
readonly attribute unsigned long snapshotLength;
9891+
9892+
Node? iterateNext();
9893+
Node? snapshotItem(unsigned long index);
9894+
};
9895+
</pre>
9896+
9897+
9898+
<h3 id=interface-xpathexpression>Interface {{XPathExpression}}</h3>
9899+
9900+
<pre class=idl>
9901+
[Exposed=Window]
9902+
interface XPathExpression {
9903+
// XPathResult.ANY_TYPE = 0
9904+
XPathResult evaluate(Node contextNode, optional unsigned short type = 0, optional XPathResult? result = null);
9905+
};
9906+
</pre>
9907+
9908+
9909+
<h3 id=mixin-xpathevaluatorbase>Mixin {{XPathEvaluatorBase}}</h3>
9910+
9911+
<pre class=idl>
9912+
callback interface XPathNSResolver {
9913+
DOMString? lookupNamespaceURI(DOMString? prefix);
9914+
};
9915+
9916+
interface mixin XPathEvaluatorBase {
9917+
[NewObject] XPathExpression createExpression(DOMString expression, optional XPathNSResolver? resolver = null);
9918+
XPathNSResolver createNSResolver(Node nodeResolver);
9919+
// XPathResult.ANY_TYPE = 0
9920+
XPathResult evaluate(DOMString expression, Node contextNode, optional XPathNSResolver? resolver = null, optional unsigned short type = 0, optional XPathResult? result = null);
9921+
};
9922+
Document includes XPathEvaluatorBase;
9923+
</pre>
9924+
9925+
9926+
<h3 id=interface-xpathevaluator>Interface {{XPathEvaluator}}</h3>
9927+
9928+
<pre class=idl>
9929+
[Exposed=Window, Constructor]
9930+
interface XPathEvaluator {};
9931+
9932+
XPathEvaluator includes XPathEvaluatorBase;
9933+
</pre>
9934+
9935+
<p class=note>For historical reasons you can both construct {{XPathEvaluator}} and access the same
9936+
methods on {{Document}}.
9937+
9938+
9939+
98589940
<h2 id=historical>Historical</h2>
98599941

98609942
<p>As explained in <a href="#goals">goals</a> this standard is a significant revision of various

0 commit comments

Comments
 (0)