Skip to content

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

Merged
dipikabh merged 2 commits into
mdn:mainfrom
gords2:document-evaluate-resulttype-default
Jun 26, 2026
Merged

Document.evaluate(): document resultType default and mark optional parameters#44534
dipikabh merged 2 commits into
mdn:mainfrom
gords2:document-evaluate-resulttype-default

Conversation

@gords2

@gords2 gords2 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

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
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Preview URLs (1 page)

(comment last updated: 2026-06-26 18:14:11)

Comment thread files/en-us/web/api/document/evaluate/index.md Outdated

@dipikabh dipikabh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! The updates look good.

Thank you, @gords2! And congratulations on landing your first PR on MDN 🎉

@dipikabh dipikabh merged commit 61db27d into mdn:main Jun 26, 2026
9 checks passed
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

3 participants