jsdom icon indicating copy to clipboard operation
jsdom copied to clipboard

Default type to XPathResult.ANY_TYPE in XPathExpression.evaluate

Open deej-io opened this issue 9 months ago • 3 comments

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

deej-io avatar May 20 '24 14:05 deej-io