FontoXML / fontoxpath

A minimalistic XPath 3.1 implementation in pure JavaScript
MIT License
135 stars 17 forks source link

`evaluateXPath.STRINGS_TYPE` returning `number` #640

Closed egh closed 6 months ago

egh commented 6 months ago

I've encountered a situation with the latest release of fontoxpath that returns a number when I would expect a string.

> fontoxpath.evaluateXPathToStrings("100")
[ '100' ] // string array, expected
> fontoxpath.evaluateXPathToString("100")
'100' // string, expected
> fontoxpath.evaluateXPath("100", null, null, fontoxpath.evaluateXPath.STRINGS_TYPE)
100 // a number, unexpected
> typeof fontoxpath.evaluateXPath("100", null, null, fontoxpath.evaluateXPath.STRINGS_TYPE)
'number'
bwrrp commented 6 months ago

In the code you included you're passing the type constant as the fourth argument to evaluateXPath. This fourth argument is actually the variables object, the expected return type should be the fifth.

egh commented 6 months ago

:facepalm: Thank you for the explanation!