ilinsky / jquery-xpath

jQuery XPath plugin (with full XPath 2.0 language support)
180 stars 64 forks source link

distinct-value() returns all occurrences instead of one per distinct value #2

Closed somelinguist closed 11 years ago

somelinguist commented 11 years ago

Calling distinct-value() is returning all occurrences of a value instead of distinct values. For example, distinct-value(//@lang) returns ["en", "en", "en", "es"] instead of ["en", "es"].

Changing lines #5436 and #5438 of jquery.xpath.js to use .value instead of .valueOf() seems to fix the problem:

... vValue = oSequence1[nIndex].value; ... if (oSequence[nRightIndex].value === vValue)

Thanks for the great script! ...

lautarorivas commented 11 years ago

@somelinguist : Thanks for this fix ! @ilinsky : Thanks for this great script !

ilinsky commented 11 years ago

@somelinguist, thanks for spotting the problem and suggesting fix. I'll be able to validate it and commit only mid march, so if someone else wants to fix, commit and open pull request earlier, you are welcome. I guess you would need to fix it in https://github.com/ilinsky/xpath.js project, as the xpath engine is included with the plugin as module.

Thanks for your support!

ilinsky commented 11 years ago

Fixed per rev be3ec7519c26da57d490235c38338e10942f5b93 in https://github.com/ilinsky/xpath.js This project will be updated shortly

ilinsky commented 11 years ago

Fixed in 0.2.4 rev 90076c0fab862f7fdd34c954f0345014ddf08859