content
content copied to clipboard
Document.evaluate(): document resultType default and mark optional parameters
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 toANY_TYPE(0)." (the issue's specific request).namespaceResolver— added{{optional_inline}}and noted it defaults tonull.result— added{{optional_inline}}and clarified that omitting it (not only passingnull) creates a newXPathResult.
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.