jsdom
jsdom copied to clipboard
Default type to XPathResult.ANY_TYPE in XPathExpression.evaluate
I got a DOMException when using the HTMX library inside JSDOM, as it does not provide an argument for the type
parameter in XPathExpression.evaluate. This PR allows the type
parameter to be optional and defaults the value to XPathResult.ANY_TYPE (0).
The whatwg living DOM spec states that the type argument should default to 0 (any): https://dom.spec.whatwg.org/#interface-xpathexpression.
Whilst the IDL in the level 3 XPath spec doesn't state explicitly that the type parameter is optional, it does use the phrase "If a specific type is specified" in the parameter description, which implies optionality: (https://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathExpression). Therefore, I believe this patch is spec-compliant on both counts.
Fixes #3422