Re: [whatwg/dom] Copy the DOM XPath interfaces from the WHATWG wiki (#763)

gsnedders commented on this pull request.



> +  XPathResult evaluate(Node contextNode,
+                       optional unsigned short type,
+                       optional XPathResult? result);
+};
+</pre>
+
+<h3 id=mixin-xpathevaluatorbase>Mixin {{XPathEvaluatorBase}}</h3>
+
+<pre class=idl>
+callback interface XPathNSResolver {
+  DOMString? lookupNamespaceURI(DOMString? prefix);
+};
+
+interface mixin XPathEvaluatorBase {
+  [NewObject] XPathExpression createExpression(DOMString expression,
+                                               optional XPathNSResolver? resolver);

```suggestion
                                               optional XPathNSResolver? resolver = null);
```

> +  readonly attribute Node? singleNodeValue;
+  readonly attribute boolean invalidIteratorState;
+  readonly attribute unsigned long snapshotLength;
+
+  Node? iterateNext();
+  Node? snapshotItem(unsigned long index);
+};
+</pre>
+
+<h3 id=interface-xpathexpression>Interface {{XPathExpression}}</h3>
+
+<pre class=idl>
+[Exposed=Window]
+interface XPathExpression {
+  XPathResult evaluate(Node contextNode,
+                       optional unsigned short type,

```suggestion
                       optional unsigned short type = 0 /* ANY_TYPE */,
```

> +  readonly attribute boolean invalidIteratorState;
+  readonly attribute unsigned long snapshotLength;
+
+  Node? iterateNext();
+  Node? snapshotItem(unsigned long index);
+};
+</pre>
+
+<h3 id=interface-xpathexpression>Interface {{XPathExpression}}</h3>
+
+<pre class=idl>
+[Exposed=Window]
+interface XPathExpression {
+  XPathResult evaluate(Node contextNode,
+                       optional unsigned short type,
+                       optional XPathResult? result);

```suggestion
                       optional XPathResult? result = null);
```

> +</pre>
+
+<h3 id=mixin-xpathevaluatorbase>Mixin {{XPathEvaluatorBase}}</h3>
+
+<pre class=idl>
+callback interface XPathNSResolver {
+  DOMString? lookupNamespaceURI(DOMString? prefix);
+};
+
+interface mixin XPathEvaluatorBase {
+  [NewObject] XPathExpression createExpression(DOMString expression,
+                                               optional XPathNSResolver? resolver);
+  XPathNSResolver createNSResolver(Node nodeResolver);
+  XPathResult evaluate(DOMString expression,
+                       Node contextNode,
+                       optional XPathNSResolver? resolver,

```suggestion
                       optional XPathNSResolver? resolver = null,
```

> +
+<h3 id=mixin-xpathevaluatorbase>Mixin {{XPathEvaluatorBase}}</h3>
+
+<pre class=idl>
+callback interface XPathNSResolver {
+  DOMString? lookupNamespaceURI(DOMString? prefix);
+};
+
+interface mixin XPathEvaluatorBase {
+  [NewObject] XPathExpression createExpression(DOMString expression,
+                                               optional XPathNSResolver? resolver);
+  XPathNSResolver createNSResolver(Node nodeResolver);
+  XPathResult evaluate(DOMString expression,
+                       Node contextNode,
+                       optional XPathNSResolver? resolver,
+                       optional unsigned short type,

```suggestion
                       optional unsigned short type = 0 /* ANY_TYPE */,
```

> +<h3 id=mixin-xpathevaluatorbase>Mixin {{XPathEvaluatorBase}}</h3>
+
+<pre class=idl>
+callback interface XPathNSResolver {
+  DOMString? lookupNamespaceURI(DOMString? prefix);
+};
+
+interface mixin XPathEvaluatorBase {
+  [NewObject] XPathExpression createExpression(DOMString expression,
+                                               optional XPathNSResolver? resolver);
+  XPathNSResolver createNSResolver(Node nodeResolver);
+  XPathResult evaluate(DOMString expression,
+                       Node contextNode,
+                       optional XPathNSResolver? resolver,
+                       optional unsigned short type,
+                       optional XPathResult? result);

```suggestion
                       optional XPathResult? result = null);
```

> @@ -9818,6 +9818,88 @@ the given value.
 
 
 
+<h2 id=xpath>XPath</h2>
+
+<cite>DOM Level 3 XPath</cite> defined an API for evaluating <cite>XPath 1.0</cite> expressions.
+[[DOM-Level-3-XPath]] [[XPath]] These APIs are widely implemented, but
+<cite>DOM Level 3 XPath</cite> is no longer maintained. The DOM Standard does not attempt to
+define any of the behavior, but the interface definitions are maintained here so that they can
+be updated when Web IDL changes. [[WEBIDL]]

There's more changes than just that, some of them simplify the API by making arguments optional.

Let's also add something, possibly just normative, saying:

 * `XPathException` is gone (just use `DOMException`)
 * The query is matched against the DOM, and therefore contrary to the XPath 1.0 data model the root element has a parent (the Document) and text nodes can be adjacent to one another. [wilful violation]

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/763#pullrequestreview-243257873

Received on Wednesday, 29 May 2019 13:38:52 UTC