Skip to content

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

Open
gords2 wants to merge 1 commit into
mdn:mainfrom
gords2:document-evaluate-resulttype-default
Open

Document.evaluate(): document resultType default and mark optional parameters#44534
gords2 wants to merge 1 commit into
mdn:mainfrom
gords2:document-evaluate-resulttype-default

Conversation

@gords2

@gords2 gords2 commented Jun 21, 2026

Copy link
Copy Markdown

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 gords2 requested a review from a team as a code owner June 21, 2026 03:48
@gords2 gords2 requested review from dipikabh and removed request for a team June 21, 2026 03:48
@github-actions github-actions Bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document the default value of resultType

2 participants