content icon indicating copy to clipboard operation
content copied to clipboard

Document.evaluate(): document resultType default and mark optional parameters

Open gords2 opened this issue 5 months ago • 0 comments

Fixes #44495.

The resultType parameter of Document.evaluate() is optional, but the page neither marked it optional nor documented its default value, so readers calling evaluate() with three arguments had no way to know what result type they'd get.

Per the WHATWG DOM Standard, the WebIDL is:

XPathResult evaluate(DOMString expression, Node contextNode,
    optional XPathNSResolver? resolver = null,
    optional unsigned short type = 0,
    optional XPathResult? result = null);

So the three trailing parameters are all optional, and type (documented here as resultType) defaults to 0, which is XPathResult.ANY_TYPE.

Changes:

  • resultType — added {{optional_inline}} and documented the default: "If omitted, it defaults to ANY_TYPE (0)." (the issue's specific request).
  • namespaceResolver — added {{optional_inline}} and noted it defaults to null.
  • result — added {{optional_inline}} and clarified that omitting it (not only passing null) creates a new XPathResult.

All three are optional in the spec, and a parameter can only be optional if every following one is too, so marking only resultType would have been inconsistent.

gords2 avatar Jun 21 '26 03:06 gords2