Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

boolean() return true for empty nodeset #85

Closed
tiritea opened this issue Nov 27, 2018 · 1 comment
Closed

boolean() return true for empty nodeset #85

tiritea opened this issue Nov 27, 2018 · 1 comment

Comments

@tiritea
Copy link

tiritea commented Nov 27, 2018

boolean() function appears to always return true for a nodeset argument, even when its empty. Whereas according XPAth spec it should return false for an empty node:

The boolean function converts its argument to a boolean as follows:
...
a node-set is true if and only if it is non-empty

@MartijnR
Copy link
Member

MartijnR commented Nov 27, 2018

Thanks! I have in the past thought the same as you.

A node-set is only empty if it doesn't return nodes, i.e. the nodes do not exist. The text content of the nodes is not taken into consideration.

I have a nice codepen for that (using browser's native XPath evaluator): https://codepen.io/MartijnR/pen/YJaBdQ

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants